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've been working on environment based on framed package, but wanted to port to mdframed due to fact that it plays better with footnotes and has more features and more active development. The issue is that I do not know mdframed internals or how to create more advanced styles with it. Also, I found the manual lacking in description on how to create advanced styles.

Is there any porting guide/reference for conversion of framed environments to mdframed environments? Or maybe at least ideas for converting this specific environment?

The environment in question is placing a line and one or two of 6 icons on margin. It has separate version for line and set of icons for odd, onepage and even situations, also separate icon sets for frames that fit on page, start of longer frames, middle frames and final frames. Frames could look like this:

icon | ......
     |               ( on this even page, line is placed on left
     |                 and icon on top, because it is start of frame)
     | ......
  ~ page break
       ...... |
              |      ( on this odd page, line is placed on right
              |icon    and icon in middle, because it's internal frame)
              |
       ...... |
  ~ page break
     | ......        ( and here it's on left again,
icon | ......          while ending icon is at bottom of frame)

or differently depending on how they lay out on pages. I got this working like I want. The relevant code looks a little like this (you can skip the %config block, but I placed it for for code to be complete and working) with lines and icons replaced by simpler versions:

\usepackage{framed}

% config
\newcommand\singletopleft{STL}
\newcommand\singletopright{STR}
\newcommand\singlebottomleft{SBL}
\newcommand\singlebottomright{SBR}
\newcommand\firstleft{FL}
\newcommand\firstright{FR}
\newcommand\middleleft{ML}
\newcommand\middleright{MR}
\newcommand\lastleft{LL}
\newcommand\lastright{LR}
\newcommand\decorleft[1]{\vrule height #1 width 0.5pt\hspace{1mm}}
\newcommand\decorright[1]{\hspace{1mm}\vrule height #1 width 0.5pt}

% \mirrorframe{left content}{right content}{minimum height}{content}
\makeatletter
\newcommand\mirrorframe[4]{%
\dimen1=#3\savebox0{#4}\dimen0=\ht0\relax
\ifdim\dimen0<\dimen1%
\dimen2=0.5\dimen1%
\advance\dimen2 by -0.5\dimen0%
\dimen0=\dimen1%
\else\dimen2=0pt\fi
\def\0{\raisebox{\dimen2}{\begin{minipage}[t]{\wd0}\usebox0\end{minipage}}}%
\def\1{\llap{\vbox to \dimen0{#1}\decorleft{\dimen0}}\0}%
\def\2{\0\rlap{\decorright{\dimen0}\vbox to \dimen0{#2}}}%
\ifodd\count0\2\else\if@twoside\1\else\2\fi\fi}
\makeatother

% \begin{mirrortest}[minimum height] ... \end{mirrortest}
\newenvironment{mirrortest}[1][2\baselineskip]{%
\def\FirstFrameCommand{\mirrorframe{\hbox{\firstleft}\vfill}{\hbox{\firstright}\vfill}{#1}}%
\def\MidFrameCommand{\mirrorframe{\vfill\hbox{\middleleft}\vfill}{\vfill\hbox{\middleright}\vfill}{#1}}%
\def\LastFrameCommand{\mirrorframe{\vfill\hbox{\lastleft}}{\vfill\hbox{\lastright}}{#1}}%
\def\FrameCommand{\mirrorframe{\hbox{\singletopleft}\vfill\hbox{\singlebottomleft}}{\hbox{\singletopright}\vfill\hbox{\singlebottomright}}{#1}}%
\MakeFramed{\advance\hsize-\width \FrameRestore}\ignorespaces}{\endMakeFramed}

I use it like this:

\usepackage{lipsum}
\begin{document}
\begin{mirrortest}
\lipsum[1-20]
\end{mirrortest}
\end{document}

The mdframed package internals seems to be a lot more complicated, that's why I don't know yet how to approach the conversion. Any help/directions would be appreciated!

share|improve this question
    
Welcome! First time I hear the documentation is lacking ;-). However the package doesn't support the odd/even combination of lines. I think this can be redefine very simple. A small question: Why do you want to switch? Which framemethod do you use? –  Marco Daniel Jul 24 '12 at 17:54
    
I do not use mdframed yet, so I don't use any framemethod yet. Looking at docs, I will probably use TikZ framemethod, because my icons are in TikZ anyway. I tried working with \newmdenv, but I do not know where to plug my own definition of commands equivalent to \FirstFrameCommand, \MidFrameCommand, etc. This is true, that docs for package framed are even shorter, but it's code is just more compact so I was able to "read it all" in relatively short time. –  Andrzej Giniewicz Jul 24 '12 at 18:08
    
Now that I think about it, is single/first/...extra what I am looking here for? –  Andrzej Giniewicz Jul 24 '12 at 18:15
    
You are right. All frame methods use the command \mdf@putbox@first, \mdf@putbox@middle and \mdf@putbox@second to draw the relevant part (see attachment of documentation). Have a closer look to the command \mdf@@setzref which test odd and even pages. You can setup the environment with hidealllines=true,leftline=true and after this expand the command with \mdfsetup{leftline=true} or \mdfsetup{rightline=true} related to odd and even pages. –  Marco Daniel Jul 24 '12 at 18:22
    
I will try it, thanks. –  Andrzej Giniewicz Jul 24 '12 at 18:32
show 1 more comment

closed as too localized by Marco Daniel, Joseph Wright Sep 21 '12 at 7:21

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Browse other questions tagged or ask your own question.