![如何强制框架框不在页面末尾被剪切](https://linux22.com/image/384632/%E5%A6%82%E4%BD%95%E5%BC%BA%E5%88%B6%E6%A1%86%E6%9E%B6%E6%A1%86%E4%B8%8D%E5%9C%A8%E9%A1%B5%E9%9D%A2%E6%9C%AB%E5%B0%BE%E8%A2%AB%E5%89%AA%E5%88%87.png)
我想知道如何让整个框架框保持在同一页上。我正在完成一份手稿,我很害怕移动前后文本来检查这一点。
我以这个例子为例这里。
\documentclass{article}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{lipsum}
\mdfdefinestyle{MyFrame}{%
linecolor=blue,
outerlinewidth=2pt,
roundcorner=20pt,
innertopmargin=\baselineskip,
innerbottommargin=\baselineskip,
innerrightmargin=20pt,
innerleftmargin=20pt,
backgroundcolor=gray!50!white}
\begin{document}
\begin{mdframed}[style=MyFrame]
\lipsum[1]
\begin{equation}
f(x) = \sin(x)
\end{equation}
\lipsum[2]
\end{mdframed}
\end{document}
我知道在图中你可以放一个“H”,像这样:
\begin{figure}[H]
\centering
\includegraphics[width=0.8\linewidth]{image}
\caption{This is the caption.}
\label{fig:label_image}
\end{figure}
是否可以使用框架框来实现?和/或固定在第 2 页?
答案1
只需放入 parbox 中即可:
\documentclass{article}
\usepackage[framemethod=TikZ]{mdframed}
\usepackage{lipsum}
\mdfdefinestyle{MyFrame}{%
linecolor=blue,
outerlinewidth=2pt,
roundcorner=20pt,
innertopmargin=\baselineskip,
innerbottommargin=\baselineskip,
innerrightmargin=20pt,
innerleftmargin=20pt,
backgroundcolor=gray!50!white}
\begin{document}
\lipsum[1-3]
\parbox{\textwidth}{\begin{mdframed}[style=MyFrame] %Added "\parbox{\textwidth}{"
\lipsum[1]
\begin{equation}
f(x) = \sin(x)
\end{equation}
\lipsum[2]
\end{mdframed}} %Added a closing "}" here
\end{document}