发布时间:2010-08-02 21:58:21
文章类别:表格制作
原文地址:http://blog.sina.com.cn/s/blog_5e16f1770100ku2l.html
QQ群:91940767/145316219/141877998/80300084/194770436
淘宝店:http://latexstudio.taobao.com
技巧续篇:http://latexstudio.net/
常见数学公式问题集下载
\documentclass[12pt,letterpaper]{report}
\newcommand\T{\rule{0pt}{2.6ex}}
\newcommand\B{\rule[-1.2ex]{0pt}{0pt}}
\begin{document}
\setcounter{table}{3}
\begin{table}[h!b!p!]
\caption{Table (default placement of caption)}
\begin{tabular}{lll}
\hline
% \T and \B would not work if it is placed here (needs to go inside cell)
Alphabet Character \T \B & Vowel & Number \\
\hline
A \T & Yes & 1 \\
B & No & 2 \\
C \B & No & 3 \\
\hline
\end{tabular}
\label{table4}
\end{table}
\end{document}

有时,我们需要把表格的标题和表格一起居左,那么可以使用如下代码:
% Example LaTeX document 5
% table with modified placement of caption
\documentclass[12pt,letterpaper]{report}
% These commands can be placed in the preamble (to be a global definition)
% or locally inside the \begin{table}...\end{table} syntax.
\newcommand\T{\rule{0pt}{2.6ex}}
\newcommand\B{\rule[-1.2ex]{0pt}{0pt}}
% Here it is: the code that adjusts justification and spacing around caption.
\makeatletter
% This does spacing around caption.
\setlength{\abovecaptionskip}{6pt}
\setlength{\belowcaptionskip}{6pt}
% This does justification (left) of caption.
\long\def\@makecaption#1#2{%
\makeatother
\begin{document}
\setcounter{table}{4}
\begin{table}[h!b!p!]
\caption{Table (modified placement of caption)}
\begin{tabular}{lll}
\hline
% \T and \B would not work if it is placed here (needs to go inside cell)
Alphabet Character \T \B & Vowel & Number \\
\hline
A \T & Yes & 1 \\
B & No & 2 \\
C \B & No & 3 \\
\hline
\end{tabular}
\label{table5}
\end{table}
\end{document}

也可用
\usepackage[justification=justified,singlelinecheck=off]{caption}
即可,参考http://bbs.chinatex.org/forum.php?mod=redirect&tid=5144&goto=lastpost#lastpost
参见:https://www.msu.edu/~harris41/latex_tablespacing.html
发表评论 取消回复