我想将mdframed
环境应用到list
如下描述的自定义环境中这里,稍作修改并如下所示。
我想在环境的每个调用周围放置一个框架(可破坏)category
。之所以需要框架,只是因为我试图模仿电子可填写表格的样式。
请参阅以下 MWE 和支持文件:
\documentclass{article}
\usepackage[]{geometry}
\usepackage{lipsum}
%\usepackage{mdframed}
\input{required_code.tex}
\newenvironment{category}[1]{%
\begin{list}{}{%
\parsep\parskip%
\setlength{\itemsep}{-\parsep}%
}\item {\bfseries \section{#1}
}%
\nobreakitem%
}%
{\end{list}}%
\begin{document}
\begin{category}{First Category}
\lipsum[1-4]
\end{category}
\begin{category}{Second Category}
\lipsum[5-10]
\end{category}
\end{document}
并且 required_code.tex 看起来像:
\makeatletter
% copied from ltlists.dtx
\def\nobreakitem{%
\@inmatherr\nobreakitem
\@ifnextchar [\@nobreakitem{\@noitemargtrue \@nobreakitem[\@itemlabel]}}
\def\@nobreakitem[#1]{%
\if@noparitem
\@donoparitem
\else
\if@inlabel
\indent \par
\fi
\ifhmode
\unskip\unskip \par
\fi
\if@newlist
\if@nobreak
\@nbitem
\else
\addpenalty\@beginparpenalty
\addvspace\@topsep
\addvspace{-\parskip}%
\fi
\else
\addpenalty\@M%only new bit!
\addvspace\itemsep
\fi
\global\@inlabeltrue
\fi
\everypar{%
\@minipagefalse
\global\@newlistfalse
\if@inlabel
\global\@inlabelfalse
{\setbox\z@\lastbox
\ifvoid\z@
\kern-\itemindent
\fi}%
\box\@labels
\penalty\z@
\fi
\if@nobreak
\@nobreakfalse
\clubpenalty \@M
\else
\clubpenalty \@clubpenalty
\everypar{}%
\fi}%
\if@noitemarg
\@noitemargfalse
\if@nmbrlist
\refstepcounter\@listctr
\fi
\fi
\sbox\@tempboxa{\makelabel{#1}}%
\global\setbox\@labels\hbox{%
\unhbox\@labels
\hskip \itemindent
\hskip -\labelwidth
\hskip -\labelsep
\ifdim \wd\@tempboxa >\labelwidth
\box\@tempboxa
\else
\hbox to\labelwidth {\unhbox\@tempboxa}%
\fi
\hskip \labelsep}%
\ignorespaces}
\makeatother