我采用以下文档中提供的两列表格的示例,并进行修改以满足我的需要:
http://tug.ctan.org/macros/latex2e/contrib/xtab/xtab.pdf
我需要将其转换为单列表。有人能告诉我如何相应地修改 latex 代码吗?
我正在使用一列表格来准备一个术语表......像这样
\begin{table}[htb]
\begin{center}
\begin{tabular}{| p{12cm} |}
\hline
\textbf{Glossary of Variables}\\
S -- Source \\
D -- Destination \\
\hline
\end{tabular}
\end{center}
我面临的问题是术语太多,表格跨度达多页。因此我需要使用 xtabular 包。希望这能解答我之前的问题。
答案1
如果您坚持的话,这里又有一个两列表,因为它可以实现良好的对齐。
\documentclass{article}
\usepackage{xtab,booktabs,array}
\usepackage[textheight=10cm]{geometry} %% just for this example.
\begin{document}
%\topcaption{This is top caption}
%\bottomcaption{This is bottom caption}
%\tablecaption{this is table caption}
\tablefirsthead{
\multicolumn{2}{c}{\bfseries Glossary of Variables} \\
\toprule
Variable&\multicolumn{1}{c}{Description}\\
\midrule}
%
\tablehead{%
\multicolumn{2}{c}%
{{\bfseries Continued from previous page}} \\
\toprule
Variable&\multicolumn{1}{c}{Description}\\ \midrule}
%
\tabletail{%
\midrule \multicolumn{2}{r}{{Continued on next page}} \\ \midrule}
\tablelasttail{%
\\\midrule
\multicolumn{2}{r}{{Concluded}} \\ \bottomrule}
\begin{xtabular}{>{\raggedleft$}p{1.5cm}<{$}>{-- \hangindent2em\hangafter1}p{\dimexpr\linewidth-1.5cm-3\tabcolsep\relax}@{}}
S & some text some text some text some text some text some text some text some
text some text some text some text some text some text some text\\
c & some text\\
d & some text\\
f & some text\\
g & some text\\
S & some text\\
c & some text\\
d & some text\\
f & some text\\
g & some text\\
S & some text\\
c & some text\\
d & some text\\
f & some text comes\\
g & some text\\
S & some text\\
c & some text\\
d & some text\\
f & some text\\
g & some text\\
S & some text\\
c & some text\\
d & some text\\
f & some text\\
g & some text\\
S & some text comes here too \\
c & some text\\
d & some text\\
f & some text\\
g & some text
\end{xtabular}%
\end{document}
再说一次,如果你坚持的话,这里有一个单列表。
\documentclass{article}
\usepackage{xtab,booktabs,array}
\usepackage[textheight=10cm]{geometry} %% just for this example.
\newcommand*{\variable}[1]{\makebox[2em][l]{$#1$ \hfill --}}
\begin{document}
%\topcaption{This is top caption}
%\bottomcaption{This is bottom caption}
%\tablecaption{this is table caption}
\tablefirsthead{
\multicolumn{1}{c}{\bfseries Glossary of Variables} \\
\toprule
\multicolumn{1}{c}{Description}\\
\midrule}
%
\tablehead{%
\multicolumn{1}{c}%
{{\bfseries Continued from previous page}} \\
\toprule
\multicolumn{1}{c}{Description}\\ \midrule}
%
\tabletail{%
\midrule \multicolumn{1}{r}{{Continued on next page}} \\ \midrule}
\tablelasttail{%
\\\midrule
\multicolumn{1}{r}{{Concluded}} \\ \bottomrule}
\begin{xtabular}{@{}>{\hangindent3em\hangafter1}p{\linewidth\relax}@{}}
\variable{S} some text some text some text some text some text some text some text some
text some text some text some text some text some text some text\\
\variable{c} some text\\
\variable{D} some text\\
\variable{c} some text\\
\variable{D} some text\\
\variable{c} some text\\
\variable{D} some text\\
\variable{c} some text\\
\variable{D} some text\\
\variable{c} some text\\
\variable{D} some text\\
\variable{c} some text\\
\variable{D} some text\\
\variable{c} some text comes\\
\variable{D} some text\\
\variable{c} some text\\
\variable{D} some text\\
\variable{c} some text\\
\variable{D} some text\\
\variable{c} some text\\
\variable{D} some text\\
\variable{c} some text\\
\variable{D} some text\\
\variable{c} some text\\
\variable{D} some text\\
\variable{c} some text comes here too \\
\variable{D} some text\\
\variable{c} some text\\
\variable{D} some text
\end{xtabular}%
\end{document}