
TeX/LaTeX で改行なしで複数行を書くにはどうすればよいでしょうか。行が垂直に重なることはあってはなりませんが、タイプライターで 1 行入力し、キャリッジを右に戻して次の行を改行なしで入力し、2 行目の文字が 1 行目の文字を上書きした場合と似た結果になるはずです。 のように、出力の周囲にフレームを配置して、\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]
。
\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}