我正在用 LaTeX 准备问卷模板。
我有以下代码(简化):
\documentclass{article}
\begin{document}
\framebox{\parbox{4cm}{
\textbf{3. How often do you have a headache?}\\
\textit{(Choose one option)}\begin{flushright}
never 0
seldom 1
often 2
\end{flushright}
}}
\end{document}
输出看起来像这样:
我的问题是:
- 为什么在 flushright 环境之前和之后会出现空白行(为方便起见,在图片上用红色标记)?
- 如何除去它们?
答案1
\flushright
并\flushleft
定义使用\trivlist
:
\def\flushright{\trivlist \raggedleft\item\relax}
\def\endflushleft{\endtrivlist}
这会增加一些额外的垂直空间。如果您不想要这些额外的空间,您可以使用\raggedleft
,\raggedright
命令代替\flushright
,\flushleft
环境。另一个选项是将\topset
(和\parskip
,和\partopset
,如果需要)设置为0pt
:
\documentclass{article}
\begin{document}
\framebox{\parbox{4cm}{
\textbf{3. How often do you have a headache?}\\
\textit{(Choose one option)}\begin{flushright}
never 0
seldom 1
often 2
\end{flushright}
}}
\framebox{\parbox{4cm}{\setlength\topsep{0pt}
\textbf{3. How often do you have a headache?}\\
\textit{(Choose one option)}\begin{flushright}
never 0
seldom 1
often 2
\end{flushright}
}}
\framebox{\parbox{4cm}{
\textbf{3. How often do you have a headache?}\\
\textit{(Choose one option)}
\begingroup\raggedleft
never 0
seldom 1
often 2\par
\endgroup
}}
\end{document}