我想知道如何使用latex中的fbox命令在框中创建多个行

use*_*105 9 latex

这是一个非常基本的问题,但我找不到这个问题的答案....我想创建一个看起来像这样的框:

                          ___________________
                          |hello1            |
                          |hello2            |
                          |hello3            |
                          |__________________|
Run Code Online (Sandbox Code Playgroud)

我在Latex中尝试了fbox命令.但是我只在一行而不是几行中得到文本.

Jos*_*ght 10

\fbox将框架放在其内容周围,但不是段落框.所以你需要一个\parbox内部\fbox

\documentclass{article}
\begin{document}
\fbox{\parbox{\textwidth}{%
hello1\\
hello2\\
hello3
}}
\end{document}
Run Code Online (Sandbox Code Playgroud)


peb*_*x11 5

另外,如果您在 \fbox 之前附加 \noindent ,即

\documentclass{article}
\begin{document}
\noindent \fbox{\parbox{\textwidth}{%
hello1\\
hello2\\
hello3
}}
\end{document}
Run Code Online (Sandbox Code Playgroud)

您可以防止盒子压痕。

  • 这应该是对约瑟夫解决方案的评论。 (3认同)