Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am looking to do two boxes with mdframed similarly to the following:

enter image description here

The first box is easy but I don't know how to place a label to the left of the second box. The positions of the dashed lines are to be fixed: in particular, the position of the second line should NOT depend on the length of the label "(i)". How should I go about doing this?

I tried using \llap but the label gets cropped.

MWE for the first box:

\documentclass{article}

\usepackage[framemethod=TikZ]{mdframed}
\usepackage{lipsum}
\mdfdefinestyle{testframe}{topline=false,rightline=false,bottomline=false,%
innerleftmargin=1em,linecolor=white,%
tikzsetting={draw=black,line width=.5pt,dashed,dash pattern= on 1pt off 3pt} }

\begin{document}

\begin{mdframed}[style=testframe]
\lipsum[3]
\end{mdframed}

\end{document}
share|improve this question
    
This question is similar to: tex.stackexchange.com/questions/52023/… Does it help? –  Marco Daniel May 29 '12 at 11:54
    
@MarcoDaniel I am not an expert in tiKZ or mdframed but indeed I tried modifying that code and without success. The problem with (my use of) the method described in your link is that the position of the line depends on the object you put next to it. –  hwhm May 29 '12 at 12:24
    
Does the (i) represent anything? –  Marco Daniel May 29 '12 at 15:46
    
@MarcoDaniel I have resolved it by myself actually... Add something like firstextra={\node[text width=3em,align=right,outer sep=0em,inner sep=0em] at ($(P-|O)+(-1.5em,-10pt)$) {(i)\;\;\;};} and also for singleextra etc. –  hwhm May 29 '12 at 16:44
    
If it works ;-). –  Marco Daniel May 29 '12 at 17:07
show 1 more comment

1 Answer 1

up vote 8 down vote accepted

Update on 31st May: Modified solution based on Marco Daniel's. Incorporated his positioning of the label, and have also included a fixed text width for the label, the "right margin" and the "skip below".


My own solution is to add to the style definition of 'testframe' as follows:

enter image description here

\documentclass{article}

\usepackage[framemethod=TikZ]{mdframed}
\usepackage{lipsum}
\usetikzlibrary{calc}
\newcommand{\mdfLABEL}[1]{\node[text width=2em,align=right,anchor=north east,%
               outer sep=0pt,inner sep=0pt] at ($ (O|-P)
                    -(\the\mdflength{innerleftmargin},0)
                    -0.5*(\the\mdflength{middlelinewidth},0)
                   - (0,\the\mdflength{innertopmargin})
                   + (0,0.5pt)
                 $) {#1};}

\mdfdefinestyle{testframe}{topline=false,rightline=false,bottomline=false,%
    innerleftmargin=1em,linecolor=white,rightmargin=2em,skipbelow=1em,%
    tikzsetting={draw=black,line width=.5pt,dashed,dash pattern= on 1pt off 3pt},%
    firstextra={\mdfLABEL{(i)}},%
    singleextra={\mdfLABEL{(i)}},%
    secondextra={\mdfLABEL{$\phantom{.}$}},%
    middleextra={\mdfLABEL{$\phantom{.}$}},%
}

\begin{document}

\begin{mdframed}[style=testframe]
\lipsum[3]
\end{mdframed}

\end{document}

Note that tikz library calc has been loaded to calculate the label's coordinates. Also, a manual adjustment of +(0,0.5pt) has been made.

share|improve this answer
1  
Nice. Note that \quad can be used in text mode too so you can omit the $’s around it. –  Tobi May 29 '12 at 22:38
    
@Tobi I did realise that one but somehow it didn't work unless I put the dollar signs in... –  hwhm May 29 '12 at 23:37
    
Thats strange, I guess it has to do with the node … But why don’t you use left alignment, like \node[text width=2em,fill=red,align=left,outer sep=0em,inner sep=0em] at ($(P-|O)+(-1em,-9pt)$) {(i)};? –  Tobi May 30 '12 at 7:26
    
@Tobi I actually intended to use right alignment. I guess it's just a matter of taste. In my example in the question, you can imagine if (i) is left-aligned a lot of space will be left to the right of (i). If you then try and place (i) about half-way in between, when you get to (iii) it will look a bit cramped. –  hwhm May 30 '12 at 11:29
1  
@hwhm: Again -- It doesn't depends on the font. It depends on the height of the first line. A simple way would be to add a \rule{0pt}{\ht\strutbox} to become the same height. Then The node can be set with \strut\smash{(i)}. –  Marco Daniel May 31 '12 at 20:00
show 6 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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