
Как написать несколько строк в 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]
.
\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}