此问题已在 1.6b 版中修复
mdframed at github
嵌套框架时,使用最内层的框架标题。所有这些框架的框架标题都是 frame3。
\documentclass{book}
\usepackage{mdframed}
\begin{document}
\begin{mdframed}[frametitle={frame1}]
asdf
\begin{mdframed}[frametitle={frame2}]
134
\begin{mdframed}[ frametitle={frame3}]
asdf1324
\end{mdframed}
\end{mdframed}
\end{mdframed}
\end{document}
(mdframed v1.4)
答案1
编辑:我已将新测试版本上传到 github。请查看。
https://github.com/marcodaniel/mdframed
使用当前版本,您无法更改此行为。要分配框架标题,我使用一个组,内容保存在一个框中。要获得对框的全局访问权限,我需要命令\global
。因此,在您的情况下,我覆盖了最后一个框架标题。
我会考虑这个请求,也许我会改变实施方案。
这是迄今为止我能提供的最佳答案
答案2
mdframed
我在文档中使用嵌套框时也遇到了问题beamerposter
(嵌套框在海报上很常见)。我决定尝试tcolorbox
一下,它对任意嵌套的框都没有问题(此示例是从 CTAN 包示例文件中窃取的):
\documentclass{article}
\usepackage{tcolorbox}
\begin{document}
\section{Boxes in boxes}
\begin{tcolorbox}[colback=yellow!10!white,colframe=yellow!50!black,
every box/.style={fonttitle=\bfseries},title=Box]
\begin{tcolorbox}[enhanced,colback=red!10!white,colframe=red!50!black,
colbacktitle=red!85!black,
title=Box inside box,drop fuzzy shadow]
\begin{tcolorbox}[beamer,colframe=blue!50!black,title=Box inside box inside box]
An now for something completely different: Boxes!\par\medskip
\newtcbox{\mybox}{nobeforeafter,tcbox raise base,colframe=green!50!black,colback=green!10!white,arc=0pt}
\mybox{This} \mybox{is} \mybox{another} \mybox{box.}
\end{tcolorbox}
\end{tcolorbox}
\end{tcolorbox}
\end{document}
看看美丽的文档有大量示例。特别值得注意的是可用的皮肤,例如TikZ
内部使用的“增强”皮肤。通过它,您可以创建您认为不可能在 Latex 中实现的盒子设计,请看一看这里。
因此,虽然这可能无法解决您的问题,但它为在 Latex 中排版嵌套框架提供了一个很好的替代方案。