0

I'm using mdframed to surround my theorem environment with a double line on the left side (trying to reproduce Hatcher's "Algebraic Topology"). It works nearly perfectly, except for two little horizontal gray lines joining my main vertical lines:

enter image description here

Here is a minimal code which produced the above picture:

\documentclass{article}
\usepackage{lipsum}
\usepackage{amsthm}
\usepackage{tikz}
\usepackage[framemethod=tikz]{mdframed}

\newtheorem{thm}{Theorem}
\mdfdefinestyle{double-line}{%
outerlinewidth=0.4pt,%
innerlinewidth=0.4pt,%
middlelinewidth=1.5pt,%
middlelinecolor=white,%
innertopmargin=-6.5pt,%
innerbottommargin=1pt,% 
innerleftmargin = 5pt,%
bottomline=false,%
topline=false,%
rightline=false}
\surroundwithmdframed[style=double-line]{thm}

\begin{document}
\begin{thm}
\lipsum[3]
\end{thm}
\end{document}

Does anybody have any idea why these gray lines appear, and how to remove them?


EDIT: Thanks to @Sigur's comment, I found Hatcher's solution on his website (http://pi.math.cornell.edu/~hatcher/AT/typography.html, point 4) :

\long\def\proclaim #1. #2\par{\bigbreak\vbox{\hbox {\vrule\kern1.5pt\vrule
\everypar{\leftskip 5pt\rightskip 4pt}\vbox{\noindent {\bf #1.\enspace}{\sl#2}}}}
\par\ifdim\lastskip<\medskipamount \removelastskip\penalty55\medskip\fi}

However, I'm not sure how to use this code such that it surrounds my theorem environment. Any idea ?


EDIT2/3: @Bernard's solution is almost perfect, but I noticed that it behaves badly with lists when not using parskip, and it behaves badly with short ending line when using parskip.

With parskip

Spacing between between theorem environment and proof environment are too big, but it seems unrelated to the double bar environment, so I created another question (see here).

Nonetheless, when a theorem environment finishes with a short line, the double bar is not long enough:

enter image description here

\documentclass{article}
\usepackage{lipsum}
\usepackage{fullpage}

\usepackage{framed}
\usepackage{amsthm, thmtools}
\usepackage{enumitem}
\usepackage{etoolbox}

\newenvironment{dbleftbar}{%
  \def\FrameCommand{\vrule width0.6pt\hspace{0.15em}\vrule width0.6pt \hspace{0.5em}}%
  \MakeFramed {\advance\hsize-\width \FrameRestore}}%
 {\endMakeFramed}

% With parskip
\usepackage{parskip}
\declaretheorem[%
name            =Theorem,%
postheadhook    =\vspace*{\parskip}\begin{dbleftbar}\vspace*{-5pt},%
prefoothook     =\vspace*{-1pt}\end{dbleftbar}%
]{Thm}

\begin{document}
\begin{Thm}\leavevmode
\begin{enumerate}[wide=0pt, leftmargin=*]
    \item Lorem i
\end{enumerate}
\end{Thm}
\hrule

\begin{Thm}\leavevmode
\begin{enumerate}[wide=0pt, leftmargin=*]
    \item Lorem ip
\end{enumerate}
\end{Thm}
\hrule

\begin{Thm}
Lorem
\end{Thm}
\hrule

\begin{Thm}
Lorem ip
\end{Thm}
\hrule
\end{document} 

Without parskip

Here, the double bar is much longer when using list.

enter image description here

  • 2
    If I am not wrong, you can find the macros used by Hatcher in its personal webpage. – Sigur Jan 2 at 16:20
  • @Sigur: the nosep option from enumitem is enough. – Bernard Jan 3 at 16:15
  • @Bernard, thanks for letting me know. I didn't know that option. – Sigur Jan 3 at 16:16
  • For the short line, adding \strut at the end should fix the problem. Yes, it's a manual adjustment, but worth the effort, per Knuth's philosophy. – barbara beeton Jan 4 at 19:44
  • Yep, I guess if no better solution arises I can always adjust space manually. That is quite unsatisfying though (also because this is quite a weird bug that would be worth solving once and for all) – Trynopsis Jan 4 at 20:28
3

I propose a solution with the framed package and thmtools. Framed defines aleftbar environment, that I modified to obtain a doublebar via a leftdblbar environment:

\documentclass{article}
\usepackage{lipsum}
\usepackage{framed}
\usepackage{amsthm, thmtools}

\newenvironment{dbleftbar}{%
  \def\FrameCommand{\vrule width0.6pt\hspace{0.15em}\vrule width0.6pt \hspace{0.5em}}%
  \MakeFramed {\advance\hsize-\width \FrameRestore}}%
 {\endMakeFramed}

\declaretheorem[name=Theorem, postheadhook=\begin{dbleftbar}\rule{0pt}{2ex}, prefoothook=\smallskip\end{dbleftbar}]{Thm}

\begin{document}

\begin{Thm}
\lipsum[11]
\end{Thm}

\end{document} 

enter image description here

  • thanks a lot ! that's excatly what I needed. (If anybody has an explanation for these gray lines, I'm still interested.) – Trynopsis Jan 2 at 20:52
  • I noticed that the spacing is much bigger when using lists. Any idea how to fix this? – Trynopsis Jan 3 at 13:34
  • Do you mean the theorem contents ends with a list? – Bernard Jan 3 at 14:07
  • yes. I added an edit to my original answer – Trynopsis Jan 3 at 14:08
  • For the spacing after a list, load enumitem and use \begin{enumerate}nosep]. I would add , for aesthetic reasons, [wide=0pt, margin*, font=\upshape]. For parskip, I don't see any peoblem loading this package. Could you post a small code showing the problem? – Bernard Jan 3 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.