\setlength\fboxrule{2pt}\setlength\fboxsep{2mm}
\fbox{ Let $f:[0,1] \to \mathbb{R}$ be a continuous function. If $f$ is infinitely differentiable, \\ then prove that $f$ coincides with a polynomial.}
当我使用此命令时,会创建框,但文本无法正确对齐,这意味着文本不会自动进入下一行,而是以某种不稳定的方式继续。我希望有人能理解我想说的话。
答案1
您所描述的并没有不妥;对于 \fbox 来说,这是正常行为,它不会将其文本置于段落模式。
您需要在 fbox 内使用 parbox,如下所示:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\noindent\setlength\fboxrule{2pt}\setlength\fboxsep{2mm}%
\newlength{\boxwidth}%
\setlength{\boxwidth}{\textwidth}%
\addtolength{\boxwidth}{-2\fboxrule}%
\addtolength{\boxwidth}{-2\fboxsep}%
\fbox{\parbox{\boxwidth}{Let $f:[0,1] \to \mathbb{R}$ be a continuous function. If $f$ is infinitely differentiable, \ then prove that $f$ coincides with a polynomial.}}
\end{document}
或者更好的是,使用框架包及其同名环境。
\documentclass{article}
\usepackage{amsmath,framed}
\begin{document}
\setlength{\FrameRule}{2pt}
\setlength{\FrameSep}{2mm}
\begin{framed}
\noindent Let $f:[0,1] \to \mathbb{R}$ be a continuous function. If $f$ is infinitely differentiable, \ then prove that $f$ coincides with a polynomial.}
\end{framed}
\end{document}