mdframed 和 minipage

mdframed 和 minipage

我正在尝试找到一种方法来使用 mdframed 将框架分离到下一页,但知识不足对我没有帮助。我的努力是尝试和效果......到目前为止没有结果。我知道有类似的问题。但我想要的是一种保持示例中所示环境的方法。请帮忙。

\documentclass[b5paper,11pt]{book} 
\usepackage{mdframed}
\usepackage{lipsum}
\usepackage{tikz}
\usepackage{lipsum}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newlength{\PlaisioBoxWidth}
\newsavebox{\KokkinoRoundedBox}
\newenvironment{RedBox}[1][\dimexpr\linewidth]
{\setlength{\PlaisioBoxWidth}{\dimexpr#1}
  \begin{lrbox}{\KokkinoRoundedBox}
    \begin{minipage}
      {\PlaisioBoxWidth}   }%
{
\end{minipage}
  \end{lrbox}
  % \begin{center}
  \begin{tikzpicture}%
    \draw node[draw=black,fill=red!15,rounded corners,%
    inner sep=1ex,text width=\PlaisioBoxWidth]%
    {\usebox{\KokkinoRoundedBox}};
  \end{tikzpicture}
  % \end{center}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\begin{document}
%
\begin{RedBox}
\lipsum[1]
\end{RedBox}
% 
\begin{RedBox}
 \lipsum[1-6]
\end{RedBox}
%
\end{document}

答案1

我不确定我是否理解了你的问题,但我认为你想使用mdframed。下面我定义了MyRedBox一种模仿你的minipage但允许分页的版本。你的minipage版本为红色,mdframed版本为蓝色:

在此处输入图片描述

笔记:

  • 包裹showframe包用于显示页边距。请注意,您的minipage环境会进入页边距。我猜您并不想要这种行为,所以没有调整右边距mdframed

代码:

\documentclass[b5paper,11pt]{book} 
\usepackage[framemethod=tikz]{mdframed}
\usepackage{lipsum}
\usepackage{tikz}
\usepackage{lipsum, showframe}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newlength{\PlaisioBoxWidth}
\newsavebox{\KokkinoRoundedBox}
\newenvironment{RedBox}[1][\dimexpr\linewidth]
{\setlength{\PlaisioBoxWidth}{\dimexpr#1}
  \begin{lrbox}{\KokkinoRoundedBox}
    \begin{minipage}
      {\PlaisioBoxWidth}   }%
{
\end{minipage}
  \end{lrbox}
  % \begin{center}
  \begin{tikzpicture}%
    \draw node[draw=black,fill=red!15,rounded corners,%
    inner sep=1ex,text width=\PlaisioBoxWidth]%
    {\usebox{\KokkinoRoundedBox}};
  \end{tikzpicture}
  % \end{center}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\newmdenv[backgroundcolor=blue!15, roundcorner=5pt, usetwoside=false, leftmargin=0.6cm]{MyRedBox}
\begin{document}
%
\begin{RedBox}
\lipsum[1]
\end{RedBox}
% 
\begin{MyRedBox}
 \lipsum[1-6]
\end{MyRedBox}
%
\end{document}

相关内容