我需要以表格格式创建目录,并在主题标题中换行。页码当前位于每个单元格的顶部。在标题换行的行中,我需要将页码对齐到底部。这是我的代码:
\begin{tabularx}{\linewidth}{ l X l }
Figure & & Page \\
1.1.1 & test text text text text text text text text text text text text text text text text text text \dotfill & 10 \\
1.1.2 & line \dotfill & 12 \\
\end{tabularx}
答案1
这可能是您正在寻找的解决方案,尽管它有点笨拙。您必须包含array
包才能获得b{}
表格对齐选项。
\documentclass{article}
\usepackage{array}
\begin{document}
\begin{tabular}{b{0.1\linewidth}b{0.8\linewidth}p{0.1\linewidth}}
Figure & & Page \\
1.1.1 & test text text text text text text text text text text text text text text text text text text \dotfill & 10 \\
1.1.2 & line \dotfill & 12 \\
1.1.3 & a lot of text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text \dotfill & 15 \\
\end{tabular}
\end{document}
您要做的是编译上面的代码,然后查找中间列位于多行上的行:
然后在图表编号后插入\newline
,这样它就会向上移动一行。因此,在这种情况下,表格将如下所示:
\begin{tabular}{b{0.1\linewidth}b{0.8\linewidth}p{0.1\linewidth}}
Figure & & Page \\
1.1.1\newline & test text text text text text text text text text text text text text text text text text text \dotfill & 10 \\
1.1.2 & line \dotfill & 12 \\
1.1.3\newline\newline & a lot of text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text \dotfill & 15 \\
\end{tabular}
最终结果:
答案2
\documentclass{article}
\usepackage{tabularx}
\newcommand\DotsPage [1]{\dotfill\rlap{\kern2\tabcolsep #1}&}
\begin{document}
\begin{tabularx}{\linewidth}{ l X l }
Figure & & Page \\
1.1.1 & test text text text text text text text text text text
text text text text text text text text\DotsPage{10}\\
1.1.2 & line test text text text text text text text text text text
text text text text text text text text\DotsPage {12}\\
1.1.3 & line for comparison\dotfill & 13
\end{tabularx}
\end{document}
答案3
这些内容几乎总是最好设置为列表而不是表格,这里只是使用enumerate
,但您可能需要自定义列表格式(enumitem
包可能会有所帮助)
\documentclass{article}
\begin{document}
\def\Dotfill{{\def\hfill{\hskip4em plus 1fill}\dotfill}}
\begin{enumerate}
\item[1.1.1] test text text text text text text text text text text text text text text text text text text \Dotfill 10
\item[1.1.2] line \Dotfill 12
\end{enumerate}
\end{document}