以下问题基于这。
我确信这是一个非常基本的问题,但我仍处于初学者水平。
为了提高可读性和易用性,我把以下内容放在了新环境中
\newenvironment{flowtable}[2]
{
\renewcommand\arraystretch{1.4}\arrayrulecolor{LightSteelBlue3}
\captionsetup{font=blue, labelfont=sc, labelsep=quad,
skip=0.5\baselineskip}
% header and footer information
\topcaption{#1} \label{tab:timeline}
\tablefirsthead{\toprule}
\tablehead{\multicolumn{2}{c}{\color{LightSteelBlue3}\textsc{Table \ref{tab:timeline}}, cont'd}\\[0.6ex]
\toprule}
\tablelasttail{\bottomrule}
\xentrystretch{#2} %table length, negative number means longer table, given in fraction, 0.15 means 15%
\begin{xtabular}{@{\,}r <{\hskip 2pt} !{\foo} >{\RaggedRight\arraybackslash}p{5cm}}
}
{
\end{xtabular}
}
现在我可以使用它作为
\begin{flowtable}{My List}{-0.15}
1947 & AT\&T Bell Labs develop the idea of cellular phones\\
1968 & Xerox Palo Alto Research Centre envisage the `Dynabook'\\
1971 & Busicom `Handy-LE' Calculator\\
1973 & First mobile handset invented by Martin Cooper\\
1978 & Parker Bros.\ Merlin Computer Toy\\
\end{flowtable}
这是可行的。有没有更好的方法?如何为选项设置一些默认值并向用户提供建议以表明输入的目的?
答案1
在下面的 MWE 中,我纠正了环境定义中的缺失%
,并将标签添加为变量。
现在环境的定义是
%\begin{flowtable}{caption}{length}{label}
其中,caption
作为打印标题的文本、length
作为命令的长度\xentrystretch{#2}
以及label
作为命令中使用的变量标签的新\ref
。
请参阅以下完整的 WE
\documentclass[a4paper,twoside,twocolumn,11pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{xtab}
\usepackage[TS1,T1]{fontenc}
\usepackage{fourier, heuristica}
\usepackage{array, booktabs, caption, ragged2e}
\usepackage[x11names,table]{xcolor}
\DeclareCaptionFont{blue}{\color{LightSteelBlue3}}
\newcommand{\foo}{\color{LightSteelBlue3}\makebox[0pt]{\textbullet}\hskip-0.5pt\vrule width 1pt\hspace{\labelsep}}
%\begin{flowtable}{caption}{length}{label}
\newenvironment{flowtable}[3]
{
\renewcommand\arraystretch{1.4}\arrayrulecolor{LightSteelBlue3}%
\captionsetup{font=blue, labelfont=sc, labelsep=quad,
skip=0.5\baselineskip}%
% header and footer information
\topcaption{#1} \label{#3}%
\tablefirsthead{\toprule}%
\tablehead{\multicolumn{2}{c}{\color{LightSteelBlue3}\textsc{Table \ref{#3}}, cont'd}\\[0.6ex]
\toprule}%
\tablelasttail{\bottomrule}%
\xentrystretch{#2} %table length, negative number means longer table, given in fraction, 0.15 means 15%
\begin{xtabular}{@{\,}r <{\hskip 2pt} !{\foo} >{\RaggedRight\arraybackslash}p{5cm}}%
}%
{%
\end{xtabular}%
}
\begin{document}
\begin{flowtable}{My List}{-0.15}{tab:test}
1947 & AT\&T Bell Labs develop the idea of cellular phones\\
1968 & Xerox Palo Alto Research Centre envisage the `Dynabook'\\
1971 & Busicom `Handy-LE' Calculator\\
1973 & First mobile handset invented by Martin Cooper\\
1978 & Parker Bros.\ Merlin Computer Toy\\
\end{flowtable}
In table~\ref{tab:test} we can see ...
\end{document}
及其结果: