Given the quite long 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}
I get:
Where I have two problems:
- The hang/hung bars do not have the same distance to text (In particular the space from end of theorem+listings to the hung below is too large. But there are also other problems: for example "Theorem Env:" to hung above)
- The multicol environment is not left aligned (may be caused by itemize which is needed to have the listings side-by-side)
I tried a lot with vspace hackery, but for at least at one of the places a problem persisted ;(
And is it possible to have the multicols/itemize in a self-defined environment to have everything more compact?
best regards, Markus
multicol
environment is left aligned, but the indentation of thecode
environment is a consequence of the fact that it's within anitemize
environment. even though the\item
label is absent. space is left for it at the beginning of the line..itemize
. one of the list-enhancement packages, i've forgotten which, has a "resule" facility that allows one to continue numbering in anenumerate
environment, but you wouldn't even need that withitemize
since there's nothing you need to keep track of. just exit fromitemize
and go back in after the code block.\begin{itemize}\item[]\end{itemize}
within the two code envs? Or is there a way to define column breaks in multicol without any itemize?\columnbreak
that you can use to break after the code on the left. maybe even\par
would work.