# Title above left line

I'm trying to create a mdframed environment where

1. The title is repeated on every page (works fine with repeatframetitle)
2. the title is left aligned relative to the normal text and this implies that the left line should start below the title.

Can someone help me with 2? How do I remove the line? And how to get rid of the ugly 10.4pt?

\documentclass[parskip=half-]{scrartcl}
\usepackage{lipsum}
\usepackage[framemethod=tikz]{mdframed}

\newmdenv
[leftmargin=0pt,
topline=false,rightline=false,
frametitle={\hspace{-10.4pt}I want the title here and no line beside it},
repeatframetitle=true,
everyline=true
]{test}

\begin{document}

\lipsum[1]

\begin{test}
\lipsum\lipsum
\end{test}

\end{document}


If tcolorbox is a valid option you can try with

\documentclass[parskip=half-]{scrartcl}
\usepackage{lipsum}

\usepackage{tcolorbox}
\tcbuselibrary{skins,breakable,hooks}

\tcbset{%
% Title boxes will be added with overlays
mytitle/.code={%
\ifstrempty{#1}{}{\pgfkeysalso{%
top=\baselineskip,
overlay unbroken and first app = {%
\node[rectangle, inner sep=0pt, outer sep=0pt,
anchor=south west,font=\bfseries]
at (frame.north west)%
{\strut#1};},
overlay middle and last app = {%
\node[rectangle, inner sep=0pt, outer sep=0pt,
anchor=south west,font=\bfseries]
at (frame.north west)%
{\strut#1};},
enlarge top by = \baselineskip,
enlarge top at break by= 0mm,
}}},
}

\newtcolorbox{test}[1]{
breakable, enhanced,%
frame hidden, interior hidden, segmentation hidden,
boxsep=0mm, right=0mm, rightrule=0mm, % aligns text to the right
overlay unbroken={\draw (frame.north west)|-(frame.south east);},
overlay first={\draw (frame.north west)|-(frame.south east);},
overlay middle={\draw (frame.north west)|-(frame.south east);},
overlay last={\draw (frame.north west)|-(frame.south east);},
mytitle={#1}
}

\begin{document}

\lipsum[1]

\begin{test}{I want the title here and no line beside}
\lipsum\lipsum
\end{test}

\end{document}

• tcolorbox is an option, but I don't know if I dare to use a new package with 200 pages of documentations for this project ;-). I have a quite tight time line. Do you know how I can align the text on the right to the normal right margin? I tried boxsep=0mm, right=0mm but there is still a small offset. And do you have some experience about the stability of the breakable frames? I don't want to have to fight against lonely lines or titles. Dec 5, 2013 at 14:46
• Does adding boxrule=0mm or rightrule=0mm to your test helps? It looks better to me. I'm not an expert but draft skin draws and measures all box components. Add it after breakable, enhanced and see what happens. Dec 5, 2013 at 15:28
• Yes rightrule=0mm did the trick (together with boxrule=0mm and right=0mm). Dec 5, 2013 at 15:42

One possibility would be to draw the lines manually using mdframed's nodes (O) (lower left corner) and (P) (upper right corner) and place the title in a node above (O |- P) (upper left corner). (This works with framemethod=tikz only.)

It is then necessary to provide a suitable definition for singleextra, firstextra, middleextra and secondextra:

\documentclass[parskip=half-]{scrartcl}
\usepackage{lipsum}
\usepackage[framemethod=tikz]{mdframed}
\newcommand*\testtitle{I want the title here and no line beside it}
\tikzset{
testtitle/.style={
anchor = south west,
font = \bfseries,
inner xsep = 0pt, outer xsep = 0pt, % align the text really at the left
outer ysep = .5ex,
overlay % necessary to avoid http://tex.stackexchange.com/q/114829/5049
}
}
\mdfdefinestyle{test}{
leftmargin = 0pt,
skipabove = 5ex, % enough space for the title node to be placed
hidealllines = true,
singleextra={
\draw (O |- P) node[testtitle] {\testtitle} -- (O) -- (P |- O) ;
},
firstextra={
\draw (O |- P) node[testtitle] {\testtitle} -- (O);
},
middleextra={
\draw (O |- P) node[testtitle] {\testtitle} -- (O);
},
secondextra={
\draw (O |- P) node[testtitle] {\testtitle} -- (O) -- (P |- O);
}
}

\newmdenv[style=test]{test}

\begin{document}

\lipsum[1]

\begin{test}
\lipsum\lipsum
\end{test}

\end{document}


• Thanks. Wouldn't it work too if I would simply draw the line with a shift and use the normal frametitle: ([yshift=-1cm]O |- P)? (Can't test now, must go to an appointment). Dec 5, 2013 at 12:44
• @UlrikeFischer Probably. I forgot you can do this... Dec 5, 2013 at 13:05
• @UlrikeFischer that won't solve the problem with the horizontal shift of the title, though... Dec 5, 2013 at 13:37
• but shouldn't is be possible to get the correct shift with the O-node too? Dec 5, 2013 at 14:49
• @UlrikeFischer I don't think that the title created with the frametitle option is placed in the tikzpicture of the frame. And even if it is I don't know if there is easy access to its node... Dec 5, 2013 at 17:53