我已经构建了包含联系人信息的数组(带有 csnames),并且我想使用循环以表格形式打印出所有联系人。
但是当表格溢出时\textwidth
,LaTeX 会允许其中一个表格伸出到边缘,并发出“过满\hbox
”警告,而不是提前中断。
为什么会这样?我该如何解决?(也许是惩罚设置?)
\documentclass{article}
\newcommand{\tableforloop}{%
\begin{tabular}{@{}l}
First Lastname\\
Address\\
Phone\\
E-mail\\
\end{tabular}%
}
\newcounter{tablestoprint}
\newcommand{\printtables}[1]{%
\setcounter{tablestoprint}{#1}%
\noindent
\loop
\tableforloop\ %
\addtocounter{tablestoprint}{-1}%
\ifnum\value{tablestoprint} > 0%
\repeat%
}
\newcommand{\myrule}{%
\noindent\rule{\textwidth}{0.4pt}%
}
\begin{document}
\myrule
\printtables{2}
\bigskip
\myrule
\printtables{6}
\end{document}
答案1
没有好的断点,因为拉伸单词间空间会超出\tolerance
。
尝试排版会得到相同的结果
\noindent
\mbox{First Lastname\hspace{\tabcolsep}\ %
\mbox{First Lastname\hspace{\tabcolsep}\ %
\mbox{First Lastname\hspace{\tabcolsep}\ %
\mbox{First Lastname\hspace{\tabcolsep}\ %
\mbox{First Lastname\hspace{\tabcolsep}\ %
\mbox{First Lastname\hspace{\tabcolsep}
使用\raggedright
或设置\spaceskip
:
\documentclass{article}
\newcommand{\tableforloop}{%
\begin{tabular}{@{}l@{}}
First Lastname\\
Address\\
Phone\\
E-mail\\
\end{tabular}%
}
\newcounter{tablestoprint}
\newcommand{\printtables}[1]{%
\setcounter{tablestoprint}{#1}%
\noindent
\loop
\tableforloop\ \ %
\addtocounter{tablestoprint}{-1}%
\ifnum\value{tablestoprint} > 0%
\repeat%
}
\newcommand{\myrule}{%
\noindent\rule{\textwidth}{0.4pt}%
}
\begin{document}
\myrule
\printtables{2}
\bigskip
\myrule
{\raggedright\printtables{6}\par}
\bigskip
\myrule
{\spaceskip=.3em plus 3em \printtables{6}\par}
\end{document}