我想知道如何让整个框架框保持在同一页上。我正在完成一份手稿,我很害怕移动前后文本来检查这一点。
我以这个例子为例这里。
\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}