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 want to make the output same as what I can make from the code shown below. But for some reasons (e.g. some frames extend to multiple pages etc.), I do not want to use ascmac package but mdframed package. What should I write in the preamble or the option of mdframed environment?

Sorry for my bad English.

\documentclass{article}
\usepackage{ascmac}
\begin{document}
\begin{itembox}[l]{foo}
bar
\end{itembox}
\end{document}
share|improve this question
    
Welcome to TeX.SE. Thanks for providing a MWE, but unfortunately it doesn't compile for me. I get Undefined control sequence. \@itembox ...\@savetbaselineshift \tbaselineshift \tbaselineshift \z@ \par \... l.4 \begin{itembox}[l]{foo}, so I don't know the desired output. –  Peter Grill Jun 13 at 5:07
    
Thanks for the comment. Maybe, you don't have ascmac.sty. You can download it from nalab.mind.meiji.ac.jp/~mk/labo/tex/style/ascmac.sty or the following link shows the desired output (note that the documentclass of this PDF is jsarticle, not article). oku.edu.mie-u.ac.jp/~okumura/texonweb/work/411.pdf –  Merzong Jun 13 at 5:40
    
@PeterGrill It seems that the ascmac in texlive 2013 produces this error. The texlive version seems to rather out of date and may be requires the obsolete platex –  Andrew Swann Jun 13 at 7:01

1 Answer 1

Here is one approach, updated as per your comments. To get round boxes you need to pass the tikz option to mdframed. The title is raised so it hits the bounding box. As we are using tikz anyway, I have put the title in a box that is a tikz node with a white background, to overwrite the rule. We use innertopmargin to move the contents up correspondingly, and adjust innerbottomargin.

To move this title further right, one option is to make the tikz picture a little wider with an invisible extra point, for example via

frametitle={\tikz{\path (0,0) (20pt,0) node[anchor=base west,rectangle,fill=white] {\strut #1};}}

This will put the title box with its left edge 20pt further to the right. Putting it all together we get:

Sample output

\documentclass{article}

\usepackage[tikz]{mdframed}

\newenvironment{itembox}[1]{\begin{mdframed}[roundcorner=10pt,
  frametitlefont=\normalfont,
  frametitleaboveskip=\dimexpr-0.7\baselineskip,skipabove=\topskip,
  innertopmargin=\dimexpr-0.65\baselineskip,
  innerbottommargin=\dimexpr0.65\baselineskip,
  frametitle={\tikz{\node[anchor=base,rectangle,fill=white] {\strut #1};}}]
}{\end{mdframed}}

\usepackage{lipsum} %for dummy text

\begin{document}

\begin{itembox}{foo}
  bar
\end{itembox}

\begin{itembox}{Longer title}
  \lipsum[1-6]
\end{itembox}

\end{document}

See the mdframed documentation or texdoc mdframed for more parameters to adjust the spacing.

share|improve this answer
    
Thank you for your answer. This is almost exactly what I want, but I want to move the frame title a little to the right. What parameter should I change? –  Merzong Jun 13 at 11:26
    
@Merzong I have updated my answer with this. –  Andrew Swann Jun 13 at 18:36
    
Thank you for the update. However, in this way, only the frame title moves upward. There is a white space between the title and the content in the frame. In order to remove this, I wrote innertopmargin=5pt-\baselineskip in the preamble but it didn't work. How can I remove this white space and move the content upward? –  Merzong Jun 15 at 5:15
    
@Merzong See my updated answer. –  Andrew Swann Jun 15 at 11:29
    
This is the error that I've found "\DeclareListParser*{\mdf@dolist}{". What version of mdframed package? –  jeecabz 9 hours ago

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.