mdframed 不会损坏,但有足够的空间容纳可损坏的 mdframed

mdframed 不会损坏,但有足够的空间容纳可损坏的 mdframed

以下是 (差不多) MWE:

\documentclass[12pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[hmargin=1.25in,vmargin=1.25in]{geometry}
\usepackage{picins}

% fix for a bug that adds space after each paragraph with `parpic` of **picins**. It is then necessary to add `\killpic` after the first paragraph (https://tex.stackexchange.com/questions/281949/how-to-prevent-parpic-from-cutting-into-every-paragraph-inside-a-proof-environm?rq=1)
\makeatletter
\newcommand{\killpic}{%
  \hangindent=0pt
  \let\par=\old@par
}
\makeatother

\usepackage[framemethod=tikz]{mdframed} 

\newcommand{\lipsumA}{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula massa, varius a, semper congue, euismod non, mi. Proin porttitor, orci nec nonummy molestie, enim est eleifend mi, non fermentum diam nisl sit amet erat. Duis semper. Duis arcu massa, scelerisque vitae, consequat in, pretium a, enim. Pellentesque congue.}

\newcommand{\lipsumB}{Ut in risus volutpat libero pharetra tempor. Cras vestibulum bibendum augue. Praesent egestas leo in pede. Praesent blandit odio eu enim. Pellentesque sed dui ut augue blandit sodales. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam nibh. Mauris ac mauris sed pede pellentesque fermentum. Maecenas adipiscing ante non diam sodales hendrerit.}

\newcommand{\logo}{\fbox{\huge{Logo}}}

\newenvironment{myenv}{%
  \begin{mdframed}[backgroundcolor=lightgray!20,linecolor=none,leftmargin=-10pt,rightmargin=-10pt]\parpic{\logo}\noindent \ignorespaces% \ignorespace is necessary, unless it, a space is added between logo and text
}{%
\end{mdframed}}

\begin{document}

\lipsumA 

\begin{myenv}
    \lipsumA 
    
    \killpic
    
    \lipsumB
\end{myenv}

\lipsumA

\begin{myenv}
    \lipsumA 
    
    \killpic
    
    \lipsumB
    
    \lipsumA
    
    \lipsumB
    
    \lipsumA
    
    \lipsumB

\end{myenv}

\end{document}

\parpic来自皮钦斯,没有错误。但我\parpic需要皮钦斯(注意皮钦斯不在 TeXlive 中,但可在 CTAN 上使用(https://ctan.org/pkg/picins);已手动安装在我的计算机上~/textmf/tex/latex/picins/pincins.sty:)。

结果 :

结果

由于有足够的空间,第二个 mdframed 怎样才能从第一页开始?

答案1

这是使用 的替代方法lettrinepicins通常lettrine用于在段落开头垂直跨越多行的大写字母,后面跟着小写字母。但是,还有一个image=true用于添加图像的键(传递给\includegraphics)。此选项跳过大写字母的处理,因此适合插入其他材料。一旦您重新定义相关\LettrineImage命令以删除该\includegraphics部分,这将变得更加灵活。

可以通过将第二个参数留空来跳过小型大写字母\lettrine

在下面的代码中,使用lraise中的键将徽标图像稍微凸起一点lettrine

梅威瑟:

\documentclass[12pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[hmargin=1.25in,vmargin=1.25in]{geometry}
\usepackage{lettrine}
\usepackage[framemethod=tikz]{mdframed} 

\newcommand{\lipsumA}{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula massa, varius a, semper congue, euismod non, mi. Proin porttitor, orci nec nonummy molestie, enim est eleifend mi, non fermentum diam nisl sit amet erat. Duis semper. Duis arcu massa, scelerisque vitae, consequat in, pretium a, enim. Pellentesque congue.}

\newcommand{\lipsumB}{Ut in risus volutpat libero pharetra tempor. Cras vestibulum bibendum augue. Praesent egestas leo in pede. Praesent blandit odio eu enim. Pellentesque sed dui ut augue blandit sodales. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam nibh. Mauris ac mauris sed pede pellentesque fermentum. Maecenas adipiscing ante non diam sodales hendrerit.}

\newcommand{\logo}{\fbox{\huge{Logo}}}

\renewcommand*{\LettrineImage}{%
\LettrineFontHook\relax%
}

\newenvironment{myenv}{%
  \begin{mdframed}[backgroundcolor=lightgray!20,linecolor=none,leftmargin=-10pt,rightmargin=-10pt]%
  \lettrine[image=true,lraise=0.2]{\logo\quad}{}%
}{%
\end{mdframed}}

\begin{document}

\lipsumA 

\begin{myenv}
    \lipsumA 
    
    \lipsumB
\end{myenv}

\lipsumA

\begin{myenv}
    \lipsumA 
    
    \lipsumB
    
    \lipsumA
    
    \lipsumB
    
    \lipsumA
    
    \lipsumB

\end{myenv}

\end{document}

结果:

在此处输入图片描述

相关内容