加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

LaTeX技巧646:表格注脚与表格内容自动对齐

(2012-11-28 22:42:23)
标签:

latex

tex

table

tabnote

tablenote

分类: 表格制作

QQ群:91940767/145316219/141877998/80300084/194770436
淘宝店:http://latexstudio.taobao.com
技巧续篇:http://latexstudio.net/
常见数学公式问题集下载

一般给表格加个注脚平时用得比较多,如下面这样的注脚方式,但是在使用过程中,我们发现,注脚往往需要我们手动调整问题,要么minipage下,要么需要限制下宽度这类问题。如何让表格注脚能够自动与表格内容对齐呢?
LaTeX技巧646:表格注脚与表格内容自动对齐
选自:http://tex.stackexchange.com/questions/51793/caption-and-footnote-width-with-ctable
效果图:
LaTeX技巧646:表格注脚与表格内容自动对齐
代码如下:
\documentclass{article}
\usepackage{booktabs}

\makeatletter
\newsavebox{\@tabnotebox}
\providecommand\tmark{} % so having ctable or not is irrelevant
\providecommand\tnote{}
\newenvironment{tabularwithnotes}[3][c]
  {\long\def\@tabnotes{#3}%
   \renewcommand\tmark[1][a]{\makebox[0pt][l]{\textsuperscript{\itshape##1}}}%
   \renewcommand\tnote[2][a]{\textsuperscript{\itshape##1}\,##2\par}
   \begin{lrbox}{\@tabnotebox}
   \begin{tabular}{#2}}
  {\end{tabular}\end{lrbox}%
   \parbox{\wd\@tabnotebox}{
     \usebox{\@tabnotebox}\par
     \smallskip\@tabnotes
   }%
  }
\makeatother

\begin{document}
\begin{table}
\centering
\caption{Somewhat long long long caption which is long}
\medskip
\begin{tabularwithnotes}{lr}
 {
  \tnote[a]{Short footnote}
  \tnote[b]{Short footnote}
 }
\toprule
Header 1 & Header 2 \\
\midrule
foo\tmark[a] & 1\tmark[b] \\
\bottomrule
\end{tabularwithnotes}
\end{table}
\end{document}

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有