如何在 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}

相關內容