Multicol 列表和 ntheorem 渲染错误

Multicol 列表和 ntheorem 渲染错误

鉴于相当长的 MWE:

\documentclass{memoir}
\usepackage[dvipsnames,table]{xcolor}
%\usepackage[showframe]{geometry}
\usepackage{mathtools}
\usepackage{needspace}
\usepackage{multido}
\usepackage{multicol}
\usepackage[thmmarks, amsmath]{ntheorem}
\usepackage{thmtools}
\usepackage{listings}

\nonzeroparskip             % Create space between paragraphs
\setlength{\parindent}{0pt} % Remove paragraph indentation
\setlength\columnsep{0pt}   % for multicol: still too much space in between

% From here:
% https://tex.stackexchange.com/questions/24101/theorem-decorations-that-stay-with-theorem-environment
\newcommand{\theoremhang}{% top theorem decoration
  \begingroup%
    \setlength{\unitlength}{.005\linewidth}% \linewidth/200
    \begin{picture}(0,0)(1.5,0)%
      \linethickness{0.45pt} \color{Black}%
      \put(-3,2){\line(1,0){206}}% Top line
      \multido{\iA=2+-1,\iB=50+-10}{5}{% Top hangs
        \color{black!\iB}%
        \put(-3,\iA){\line(0,-1){1}}% Top left hang
        \put(203,\iA){\line(0,-1){1}}% Top right hang
      }%
    \end{picture}%
  \endgroup%
}%

\newcommand{\theoremhung}{% bottom theorem decoration
  \begingroup%
    \setlength{\unitlength}{.005\linewidth}% \linewidth/200
    \begin{picture}(0,0)(1.5,0)%
      \linethickness{0.45pt} \color{Black}%
      \put(-3,0){\line(1,0){206}}% Bottom line
      \multido{\iA=0+1,\iB=50+-10}{5}{% Bottom hangs
        \color{black!\iB}%
        \put(-3,\iA){\line(0,1){1}}% Bottom left hang
        \put(203,\iA){\line(0,1){1}}% Bottom right hang
      }%
    \end{picture}%
  \endgroup%
}%

\newcommand{\theoremspace}{\needspace{2\baselineskip}}
\newcommand{\theoremspuce}{\nopagebreak\noindent}

\theoremstyle{plain}
\theoremsymbol{}%
\theoremprework{\theoremspace\theoremhang\vspace*{-1.3ex}}%
\theorempostwork{\theoremspuce\theoremhung}%
\theoremheaderfont{\upshape\bfseries}
\theoremseparator{.}
\theorembodyfont{\upshape}
\newtheorem{theorem}{Theorem}




\lstnewenvironment{code}[1][]%
{%
\noindent%
\minipage{\linewidth}%
\theoremspace%
\theoremhang%
\lstset{#1}}%
{\theoremhung\endminipage}

\begin{document}

Code Env:

\begin{code}
Test. Test. Test. Test. Test. Test.
\end{code}

Theorem Env:

\begin{theorem}
Test. Test. Test. Test. Test. Test.
\end{theorem}

Multicol Code Env:

\begin{multicols}{2}
\begin{itemize}
\item[]
\begin{code}
left
\end{code}
\item[]
\begin{code}
right
\end{code}
\end{itemize}
\end{multicols}

\end{document}

我得到:

渲染输出

我有两个问题:

  1. 悬挂/悬空条与文本的距离不一样(特别是从定理+列表末尾到下面悬挂的空间太大。但也有其他问题:例如“定理环境:”悬挂在上面)
  2. multicol 环境未左对齐(可能是由于需要并排列出列表的 itemize 导致的)

我尝试了很多种 vspace hackery 方法,但至少在其中一个地方问题仍然存在 ;(

并且,是否可以在自定义环境中使用 multicols/itemize 以使一切变得更加紧凑?

马库斯

答案1

部分解决方案是将 vspace 放在

\theorempostwork{\vspace{-1em}\theoremspuce\theoremhung}

最初我尝试将 vspace 添加到 theoremspuce,但没有成功。

相关内容