分成多頁的縮排框

分成多頁的縮排框

我正在做一份包含練習和更正的文件。我希望這些修正能夠輕易地被注意到,這樣就不會有學生無意中閱讀它並破壞它的練習。我已經為此編寫了一個環境,​​問題是它不會分成多個頁面:/

\newenvironment{solution}%
{\par\rule{1ex}{1ex}
\hspace{\stretch{1}}
\textbf{Solution}
\hspace{\stretch{1}}
\rule{1ex}{1ex}\par%
\hspace{2ex}% indent everything by 2ex
%\begin{myindentpar}{7ex}
%\quote \quote
\begin{minipage}{0.95\linewidth}% stop just before the right squares
\begin{framed}}% put a black frame
%\addtolength{\leftskip}{4cm}
%\begin{adjustwidth}{6cm}{}
%\begin{longtable}{|p{1.1\linewidth}|}
%\hline}
{\end{framed}\end{minipage}
%{\\\hline\end{longtable}
%\end{adjustwidth}
%\end{myindentpar}
%\endquote \endquote
\par
\rule{1ex}{1ex}\hspace{\stretch{1}}
\hspace{\stretch{1}}\rule{1ex}{1ex}\par}

我故意留下了我的評論嘗試,以防它對您有所啟發。

如果你找到一個稍微改變設計的解決方案,我仍然很感興趣:)

答案1

您程式碼中的問題是您將mdframedaminipage和 s 括起來,minipage不允許分頁符號。我的猜測是,您使用 來minipage定位框架角上的小方塊;然而,這不是必需的,您可以使用 , 來定位它們singleextrafirstextra而不會破壞環境中分頁符號的可能性。

一個小例子,其中我定義了兩種樣式:第一個,沒有正方形,第二個,使用正方形(我不確定您想要使用的確切長度,但您可以輕鬆地進行必要的調整):

\documentclass{article}
\usepackage[a5paper]{geometry}% just for the example
\usepackage[framemethod=tikz]{mdframed}
\usepackage{tikzpagenodes}
\usepackage{lipsum}% just to generate text for the example
\usetikzlibrary{calc}

\mdfdefinestyle{mystyle}{%
  leftmargin=2ex,
  innertopmargin=2\baselineskip,
  skipabove={\dimexpr0.5\baselineskip+\topskip\relax},
  skipbelow={\dimexpr0.5\baselineskip+\topskip\relax},
  firstextra={%
    \path let \p1=(P), \p2=(O) 
    in node[font=\bfseries] at ([yshift=-2ex]0.5*\x1-\x2,\y1) {Solution};
  }
}
\mdfdefinestyle{mysquare}{%
  leftmargin=0pt,
  rightmargin={\dimexpr4pt+2ex\relax},
  innertopmargin=2\baselineskip,
  skipabove={\dimexpr0.5\baselineskip+\topskip\relax},
  skipbelow={\dimexpr0.5\baselineskip+\topskip\relax},
  singleextra={%
  \path let \p1=(P), \p2=(O) 
    in node[font=\bfseries] at ([yshift=-2ex]0.5*\x1-\x2,\y1) {Solution};
  \fill[black] ([xshift=2pt,yshift=2pt]P) rectangle ++(1ex,1ex);
  \fill[black] ([xshift=-2pt,yshift=-2pt]O) rectangle ++(-1ex,-1ex);
  \fill[black] ([xshift=-2pt,yshift=2pt]O|-P) rectangle ++(-1ex,1ex);
  \fill[black] ([xshift=2pt,yshift=-2pt]O-|P) rectangle ++(1ex,-1ex);
  },
  firstextra={%
  \path let \p1=(P), \p2=(O) 
    in node[font=\bfseries] at ([yshift=-2ex]0.5*\x1-\x2,\y1) {Solution};
  \fill[fill=black] ([xshift=2pt,yshift=2pt]P) rectangle ++(1ex,1ex); 
  \fill[black] ([xshift=-2pt,yshift=2pt]O|-P) rectangle ++(-1ex,1ex);
  },
  secondextra={%
  \fill[fill=black] ([xshift=2pt,yshift=-2pt]O-|P) rectangle ++(1ex,-1ex); 
  \fill[black] ([xshift=-2pt,yshift=-2pt]O) rectangle ++(-1ex,-1ex);
  }
}
\newmdenv[style=mystyle]{solution}
\newmdenv[style=mysquare]{ssolution}

\begin{document}

\lipsum[1]
\begin{solution}
\lipsum[2-3]
\end{solution}
\lipsum[2]
\begin{ssolution}
\lipsum[1-2]
\end{ssolution}
\lipsum[2]

\end{document}

在此輸入影像描述

相關內容