发布时间: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} % 0.5cm as an example
\setlength{\belowcaptionskip}{6pt} % 0.5cm as an example
% This does justification (left) of caption.
\long\def\@makecaption#1#2{%
\vskip\abovecaptionskip
\sbox\@tempboxa{#1: #2}%
\ifdim \wd\@tempboxa >\hsize
#1: #2\par
\else
\global \@minipagefalse
\hb@xt@\hsize{\box\@tempboxa\hfil}%
\fi
\vskip\belowcaptionskip}
\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


点赞(0)

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部