mdframed 和 parskip

mdframed 和 parskip

这似乎很简单:我怎样才能在 mdframed 中跳过段落,就像在框外一样?它是否以某种方式“禁用”了,如果是,有什么原因吗?

这是在浮动环境中的设置方法。不知道这样做是否有用;我从另一篇文章中复制并修改了代码,所以我并不完全了解它的工作原理。

\documentclass{report}
\usepackage{geometry}
\usepackage[parfill]{parskip} 
\usepackage[framemethod=TikZ]{mdframed}
\mdfsetup{frametitlealignment=\center}
\usepackage{newfloat}

\DeclareFloatingEnvironment[fileext=frm,placement={!ht},name=Frame]{myfloat}
\newenvironment{infobox}[2][ht] {
   \begin{myfloat}[#1]
        \begin{mdframed}[roundcorner=10pt,frametitle={Box~X: #2},nobreak=false]}
    {\end{mdframed}\end{myfloat}}


\begin{document}

\chapter{}
Hello, this is text.

Using parskip with parfill option.

\begin{infobox}{Title}
Why does this not have line skips?

I would like it to look like the rest of the document.
\end{infobox}

\end{document}

截屏

抱歉,如果这是另一个问题的重复,但如果是这样,我找不到它。

答案1

正如上面评论中提到的,这似乎与LaTeX 创建者的一些临时选择。这是一个可能的解决方法。

\documentclass{report}
\usepackage{geometry}
\usepackage[parfill]{parskip} 
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\usepackage{tikzpagenodes}
\usepackage{lipsum}
\tikzset{SimpleBox/.style={draw,thick,rounded corners}}


\newcommand{\SimpleBox}[2][2pt]{%
\tikz[remember picture,overlay, baseline=(Begin.base)]{%
\node[anchor=base,inner sep=0pt,outer sep=0pt] (Begin) {\strut};}#2%
\tikz[remember picture,overlay, baseline=(End.base)]{%
\node[anchor=base,inner sep=0pt,outer sep=0pt] (End) {\strut};}%
\begin{tikzpicture}[overlay,remember picture]
\path (current page text area.north west) -- (current page text area.south west)
node(WestLine)[left]{};
\path (current page text area.north east) -- (current page text area.south east)
node(EastLine)[right]{};
\begin{scope}[on background layer]
\draw[SimpleBox] (Begin.north-|WestLine) rectangle (End.south-|EastLine);
\end{scope}
\end{tikzpicture}}

\begin{document}

Hello, this is text.

Using parskip with parfill option.


\SimpleBox{
\centerline{\textbf{Box X: Title}}
Hello, this is text.

Using parskip with parfill option also works in the box (and not just ``out of
the box'';-).
}


\end{document}

在此处输入图片描述

我知道这不能回答你的问题,但我希望它能让你获得与你想要的类似的输出。

附录:允许框跨越一个(!)分页符的代码。依赖于开创性的工作这个帖子

\documentclass{report}
\usepackage{geometry}
\usepackage[parfill]{parskip} 
\usepackage{refcount}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\usepackage{tikzpagenodes}
\usepackage{lipsum}
\newif\ifSimpleBoxOpen\SimpleBoxOpentrue
\tikzset{SimpleBox/.style={draw,thick,rounded corners}}

\usepackage{lipsum}
\newcounter{tmp}
\newcommand\tikzmark[1]{%
  \tikz[overlay,remember picture] \node (#1) {};}

\newcommand\StartBox[1][]{%
  \stepcounter{tmp}%from https://tex.stackexchange.com/a/52579/121799
  \tikz[remember picture,overlay, baseline=(Begin.base)]{%
  \node[anchor=base,inner sep=0pt,outer sep=0pt] (Begin) {\strut};}
  \label{a\thetmp}%
  \ifnum\getpagerefnumber{a\thetmp}=\getpagerefnumber{b\thetmp} \else
  \begin{tikzpicture}[overlay, remember picture]
   \path (current page text area.north west) -- (current page text area.south west)
    node(WestLine)[left]{};
   \path (current page text area.north east) -- (current page text area.south east)
    node(EastLine)[right]{};
   \begin{scope}[on background layer,blend mode=multiply]
   \ifSimpleBoxOpen
   \draw[SimpleBox,#1] ( current page text area.south-|WestLine) -- 
   (Begin.north-|WestLine) -- (Begin.north-|EastLine) --  (current page text
   area.south-|EastLine);
   \else
   \draw[SimpleBox,#1] (Begin.north-|WestLine) rectangle (current page text
   area.south-|EastLine);
   \fi
   \end{scope}
  \end{tikzpicture}%
  \fi%
}

\newcommand\EndBox[1][]{%
\tikz[remember picture,overlay, baseline=(End.base)]{%
\node[anchor=base,inner sep=0pt,outer sep=0pt] (End) {\strut};}%
  \label{b\thetmp}
  \ifnum\getpagerefnumber{a\thetmp}=\getpagerefnumber{b\thetmp}
  \begin{tikzpicture}[overlay,remember picture]
   \path (current page text area.north west) -- (current page text area.south west)
    node(WestLine)[left]{};
   \path (current page text area.north east) -- (current page text area.south east)
    node(EastLine)[right]{};
   \begin{scope}[on background layer]
    \draw[SimpleBox,#1] (Begin.north-|WestLine) rectangle (End.south-|EastLine);
   \end{scope}
  \end{tikzpicture}
  \else
  \begin{tikzpicture}[overlay,remember picture]
   \path (current page text area.north west) -- (current page text area.south west)
    node(WestLine)[left]{};
   \path (current page text area.north east) -- (current page text area.south east)
    node(EastLine)[right]{};
   \begin{scope}[on background layer,blend mode=multiply]
   \ifSimpleBoxOpen
   \draw[SimpleBox,#1] ( current page text area.north-|WestLine) -- 
   (End.south-|WestLine) -- (End.south-|EastLine) --  (current page text
   area.north-|EastLine);
   \else
   \draw[SimpleBox,#1] (Begin.north-|WestLine) rectangle (current page text
   area.south-|EastLine);
   \fi
   \end{scope}
  \end{tikzpicture}
  \fi
}

\newcommand{\SimpleBox}[2][]{%
\StartBox[#1]%
#2\EndBox[#1]}

\begin{document}

Hello, this is text.

Using parskip with parfill option.


\SimpleBox{
\centerline{\textbf{Box X: Title}}
Hello, this is text.

Using parskip with parfill option also works in the box (and not just ``out of
the box'';-).
}

\lipsum[1-4]

\SimpleBox{\lipsum[5-6]}

\end{document}

相关内容