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 really like the digression style created in mdframed digressionarrows style with custom header. I would like to extend it even further by displaying the frametitle (if it is defined) after the custom digressiontitle (i.e. Side note or Info). So far this is what I managed to do:

    \documentclass{article}

    \usepackage{tikz}
       \usetikzlibrary{calc,arrows}
    \usepackage{etoolbox}

    \usepackage[framemethod=tikz]{mdframed}
    \makeatletter
    \mdf@do@stringoption{digressiontitle=={Digression}}
    \tikzset{
      excursus arrow/.style={%
           line width=2pt,
          draw=gray!40,
          rounded corners=2ex,
          },
       excursus head/.style={
          fill=white,
          font=\bfseries\sffamily,
          text=gray!80,
          anchor=base west,
      },
    }
    \mdfdefinestyle{digressionarrows}{%
       singleextra={%
                \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
                \path let \p1=(Q), \p2=(O) in (\x1,{(\y1-\y2)/2}) coordinate (M);
                \path [excursus arrow, round cap-to]
                            ($(O)+(5em,0ex)$) -| (M) |- %
                            ($(Q)+(12em,0ex)$) .. controls +(0:16em) and +(185:6em) .. %
                            ++(23em,2ex);
                \ifx\empty\mdf@frametitle\empty
                   \node [excursus head] at ($(Q)+(2.5em,-0.75pt)$) {\mdf@digressiontitle};
                \else
                   \node [excursus head] at ($(Q)+(2.5em,-0.75pt)$) {\mdf@digressiontitle:\space\mdf@frametitle};
                \fi},
       firstextra={%
                \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
                \path [excursus arrow,-to] (O) |- %
                            ($(Q)+(12em,0ex)$) .. controls +(0:16em) and +(185:6em) .. %
                            ++(23em,2ex);
                \ifx\empty\mdf@frametitle\empty
                   \node [excursus head] at ($(Q)+(2.5em,-0.75pt)$) {\mdf@digressiontitle};
                \else
                   \node [excursus head] at ($(Q)+(2.5em,-0.75pt)$) {\mdf@digressiontitle:\space\mdf@frametitle};
                \fi},
       secondextra={%
                \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
                \path [excursus arrow,round cap-]($(O)+(5em,0ex)$) -| (Q);},
       middleextra={%
                \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
                \path [excursus arrow](O) -- (Q);},
       middlelinewidth=2.5em,middlelinecolor=white,
       hidealllines=true,topline=true,
       innertopmargin=0.5ex,
       innerbottommargin=2.5ex,
       innerrightmargin=2pt,
       innerleftmargin=2ex,
       skipabove=0.87\baselineskip,
       skipbelow=0.62\baselineskip,
    }
    \makeatother

    \newmdenv[style=digressionarrows,digressiontitle=Info]{info}
    \newmdenv[style=digressionarrows,digressiontitle=Side note]{sidenote}

    \usepackage{lipsum}

    \begin{document}

    \begin{sidenote}[frametitle=A side note 1]
    \lipsum[3]
    \end{sidenote}

    \begin{info}[frametitle=My frame]
    \lipsum[1]
    \lipsum
    \end{info}

    \end{document}

The problem with this solution is that the frametitle is still being displayed. Is there an easy way to suppress the display of frametitle by mdframed?

Update:

Here is the picture which hopefully illustrates the problem: Image showing duplicate title

As you can see, "A side note 1" appears twice, once in gray after Side note:, which should be kept, and once inside the frame above the text. This I want to suppress.

share|improve this question
    
@HarishKumar: I guess I wasn't clear enough - I'll add a picture to the question - the way I programmed it, the frametitle will appear both after Info: or Idea: and inside the frame. I would like to suppress the second appearance (inside the frame). Is this more clear? –  Omri Feb 14 at 14:51
add comment

1 Answer 1

up vote 5 down vote accepted

The easiest solution is to define a new key for your title; in this way, both elements (the frametitle and your title) are independent. This is simply done using something like

\def\mdf@mytitle{}
\define@key{mdf}{mytitle}{%
  \def\mdf@mytitle{#1}}

Now you can use \mdf@mytitle instead of the frametitle key in your internal settings and the mytitle key in the options for your mdframes:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,arrows}
\usepackage{etoolbox}
\usepackage{lipsum}

\usepackage[framemethod=tikz]{mdframed}
\makeatletter
\def\mdf@mytitle{}
\define@key{mdf}{mytitle}{%
  \def\mdf@mytitle{#1}}

\mdf@do@stringoption{digressiontitle=={Digression}}
\tikzset{
  excursus arrow/.style={%
   line width=2pt,
  draw=gray!40,
  rounded corners=2ex,
  },
   excursus head/.style={
  fill=white,
  font=\bfseries\sffamily,
  text=gray!80,
  anchor=base west,
  },
}
\mdfdefinestyle{digressionarrows}{%
   singleextra={%
\path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
\path let \p1=(Q), \p2=(O) in (\x1,{(\y1-\y2)/2}) coordinate (M);
\path [excursus arrow, round cap-to]
($(O)+(5em,0ex)$) -| (M) |- %
($(Q)+(12em,0ex)$) .. controls +(0:16em) and +(185:6em) .. %
++(23em,2ex);
\ifx\empty\mdf@mytitle\empty
   \node [excursus head] at ($(Q)+(2.5em,-0.75pt)$) {\mdf@digressiontitle};
\else
   \node [excursus head] at ($(Q)+(2.5em,-0.75pt)$) {\mdf@digressiontitle:\space\mdf@mytitle};
\fi},
   firstextra={%
\path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
\path [excursus arrow,-to] (O) |- %
($(Q)+(12em,0ex)$) .. controls +(0:16em) and +(185:6em) .. %
++(23em,2ex);
\ifx\empty\mdf@mytitle\empty
   \node [excursus head] at ($(Q)+(2.5em,-0.75pt)$) {\mdf@digressiontitle};
\else
   \node [excursus head] at ($(Q)+(2.5em,-0.75pt)$) {\mdf@digressiontitle:\space\mdf@mytitle};
\fi},
   secondextra={%
\path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
\path [excursus arrow,round cap-]($(O)+(5em,0ex)$) -| (Q);},
   middleextra={%
\path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
\path [excursus arrow](O) -- (Q);},
   middlelinewidth=2.5em,middlelinecolor=white,
   hidealllines=true,topline=true,
   innertopmargin=0.5ex,
   innerbottommargin=2.5ex,
   innerrightmargin=2pt,
   innerleftmargin=2ex,
   skipabove=0.87\baselineskip,
   skipbelow=0.62\baselineskip,
}
\makeatother

\newmdenv[style=digressionarrows,digressiontitle=Info]{info}
\newmdenv[style=digressionarrows,digressiontitle=Side note]{sidenote}

\begin{document}

\begin{sidenote}[mytitle=A side note 1]
\lipsum[3]
\end{sidenote}

\begin{info}[mytitle=My frame]
\lipsum[1]
\lipsum
\end{info}

\end{document}

enter image description here

share|improve this answer
    
Thanks! That solves my problem :-) I guess I need to learn some more about TeX internals... –  Omri Feb 15 at 9:29
add comment

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.