如何在 TeX 中写入多行而不换行?

如何在 TeX 中写入多行而不换行?

如何在 TeX/LaTeX 中不换行地输入多行?这些行不应垂直叠放在一起,但结果应该类似于您用打字机输入一行,然后将回车移回右侧,然后不换行地输入下一行时得到的结果,这样第二行的字母就会覆盖第一行的字母。您应该能够在得到的结果周围放置一个框架 - 就像\fbox,这​​样框架的顶部与最高字符垂直分隔,底部与最深字符垂直分隔\fboxsep

答案1

在此处输入图片描述

您只需将其设置\baselineskip为 0pt

\documentclass{article}

\begin{document}

\begin{center}
  \fbox{\parbox{\dimexpr\textwidth-2\fboxrule-2\fboxsep} {%
      \lineskiplimit=-\maxdimen\baselineskip=0pt\relax
      How to write several lines in
      TeX/LaTeX without line feed? The lines should not lie vertically
      on top of each other, but the result should be similar to what
      you get when you type a line with your typewriter and then move
      carriage back to the right and then type the next line without a
      line feed, so that the letters of the second line overwrite the
      letters of the first line. You should be able to put a frame
      around what you get—like a \texttt{\string\fbox}, so that the
      frame is vertically separated both at the top from the highest
      character and at the bottom from the deepest character by
      \texttt{\string\fboxsep}.}}
\end{center}

\end{document}

答案2

我只需在同一单元格周围设置带有框架的单独线条即可tabular。使用负换行符可以覆盖线条\\[-\normalbaselineskip]

1

\documentclass{article}

\begin{document}

\begin{tabular}{| l |}
  \hline
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. \\
  Vestibulum sit amet velit vel elit tincidunt placerat. \\
  Mauris sit amet magna venenatis, malesuada magna eget, venenatis ex. \\
  \hline
\end{tabular}

\bigskip

\begin{tabular}{| l |}
  \hline
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. \\[-\normalbaselineskip]
  Vestibulum sit amet velit vel elit tincidunt placerat. \\[-\normalbaselineskip]
  Mauris sit amet magna venenatis, malesuada magna eget, venenatis ex. \\
  \hline
\end{tabular}

\end{document}

相关内容