4

I'm interesting in Boxed text between pages 2nd version: exercise box with mdframed. Ho to add to this : Vertically shaded frametitle and Vertically shaded box with dropping shadow?

Yes i have seen several examples here for shadows and vertical shading but thay use styles i cannot put in mdframed.

here is another example. 2 questions: 1.ho can i change size of rounded titlebox shadow's size? 2. how can i remove that red titlebox thing? or another alternative would be to start shading from top including rectangular titleframe

\documentclass{article}
\usepackage[a5paper]{geometry}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{amsmath,amssymb}
\usetikzlibrary{shadows.blur}
\usetikzlibrary{shapes.symbols}
\usetikzlibrary{shadows}
\usetikzlibrary{calc}
\usepackage{lipsum}
\newcounter{exe}

\newenvironment{Fancybox}[1][.5\textwidth]
{%
    \stepcounter{exe}%
  \mdfsetup{%
      frametitle={%
      \tikz[baseline=(current bounding box.east),outer sep=8pt]
      \node[draw=blue!40,anchor=east,rectangle, thick,font=\color{black}, double,
       top color=blue!40,
                    bottom color=blue!5,
                    rounded corners=8pt,
                    drop shadow,
                    ]
        {\strut Exercise~\theexe};},%
    skipabove=\topskip,
    skipbelow=\topskip,
    innertopmargin=1pt,
    apptotikzsetting={\tikzset{mdfbackground/.append style={top color=blue!40, bottom color=white}}},
    linecolor=blue,%
    innerlinewidth=1pt,
    topline=true,
    shadow=true,
    rightline=true,innerleftmargin=10,innerrightmargin=10,
    frametitlerule=false,
    frametitlebackgroundcolor=red,
    shadowcolor=blue!40,
    frametitleaboveskip=\dimexpr-\ht\strutbox\relax,
    roundcorner=5pt,
    singleextra={\path let \p1=(P), \p2=(O) in node[fill=blue!40,font=\color{black}] at (P|-0,0.5*\y2+0.5*\y1) {$\clubsuit$};}
  }
  \begin{mdframed}[userdefinedwidth=#1]\allowdisplaybreaks\relax%
}
{\end{mdframed}}

\begin{document}
\lipsum[1-4]
\begin{Fancybox}[1\textwidth]
         \begin{align}
            \dot{n} &= u\cos\psi -v\sin\psi \\
            \dot{e} &= u\sin\psi + v\cos\psi
        \end{align}
        For small angles the following approximation can be used:
        \begin{align}
            \dot{n} &= u -v\delta_\psi \\
            \dot{e} &= u\delta_\psi + v
        \end{align}
\end{Fancybox}
\begin{Fancybox}[1\textwidth]
         \begin{align}
            \dot{n} &= u\cos\psi -v\sin\psi \\
            \dot{e} &= u\sin\psi + v\cos\psi
        \end{align}
        For small angles the following approximation can be used:
        \begin{align}
            \dot{n} &= u -v\delta_\psi \\
            \dot{e} &= u\delta_\psi + v
        \end{align}
\end{Fancybox}


\end{document}
Moriambar
  • 11,466

1 Answers1

4

One option using singleextra, firstextra to place the title, instead of frametitle; in this way you can easily obtain the desired shading effect for the background. To control the shadow attributes, you can use all the available keys for example scale, xshift, yshift (refer to the PGF manual). For frames without page breaks a decoration was added midways vertically on the right side (as requested in a comment):

\documentclass{article}
\usepackage[a6paper]{geometry}% just for the example
\usepackage[framemethod=tikz]{mdframed}
\usepackage{amsmath,amssymb}
\usetikzlibrary{calc}
\usetikzlibrary{shadows.blur}
\usetikzlibrary{shapes.symbols}
\usetikzlibrary{shadows}

\newcounter{exe}

\newenvironment{Fancybox}[1][\textwidth]
{\stepcounter{exe}%
  \mdfsetup{
      singleextra={%
      \node[draw=blue!40,anchor=east,rectangle, thick,font=\color{black}, double,
       top color=blue!40,
                    bottom color=blue!5,
                    rounded corners=8pt,
                    drop shadow={shadow xshift=1.5pt, shadow yshift=-1.5pt},anchor=west
] at ([xshift=20pt]O|-P)
        {\strut Example~\theexe};
\path let \p1=(P), \p2=(O) in node[fill=blue!40,font=\color{white}] at (P|-0,0.5*\y2+0.5*\y1) {$\clubsuit$};},%
      firstextra={%
      \node[draw=blue!40,anchor=east,rectangle, thick,font=\color{black}, double,
       top color=blue!40,
                    bottom color=blue!5,
                    rounded corners=8pt,
                    drop shadow={shadow xshift=1.5pt, shadow yshift=-1.5pt},anchor=west
] at ([xshift=20pt]O|-P)
        {\strut Example~\theexe};},%
    skipabove=\topskip,
    skipbelow=\topskip,
    innertopmargin=18pt,
    linecolor=red,%
    innerlinewidth=0.8pt,
    topline=true,
apptotikzsetting={\tikzset{mdfbackground/.append style={%
shade,top color=blue!35, bottom color=white}}},
    frametitleaboveskip=\dimexpr-\ht\strutbox\relax,
    roundcorner=5pt,
    linecolor=blue,%
    innerlinewidth=1pt,
    topline=true,
    shadow=true,
    rightline=true,innerleftmargin=10,innerrightmargin=10,
    shadowcolor=blue!40,
  }
  \begin{mdframed}[userdefinedwidth=#1]\relax%
}
{\end{mdframed}}

\begin{document}

\begin{Fancybox}
        To calculate the horizontal position the kinematic differential
        equations are needed:
        \begin{align}
            \dot{n} &= u\cos\psi -v\sin\psi \\
            \dot{e} &= u\sin\psi + v\cos\psi
        \end{align}
        For small angles the following approximation can be used:
        \begin{align}
            \dot{n} &= u -v\delta_\psi \\
            \dot{e} &= u\delta_\psi + v
        \end{align}
\end{Fancybox}

\begin{Fancybox}
        To calculate the horizontal position the kinematic differential
        equations are needed:
        \begin{align}
            \dot{n} &= u\cos\psi -v\sin\psi \\
            \dot{e} &= u\sin\psi + v\cos\psi
        \end{align}
        For small angles the following approximation can be used:
        \begin{align}
            \dot{n} &= u -v\delta_\psi \\
            \dot{e} &= u\delta_\psi + v
        \end{align}
        For small angles the following approximation can be used:
        \begin{align}
            \dot{n} &= u -v\delta_\psi \\
            \dot{e} &= u\delta_\psi + v
        \end{align}
\end{Fancybox}

\begin{Fancybox}[7cm]
        To calculate the horizontal position the kinematic differential equations are needed:
        \begin{align}
            \dot{n} &= u -v\delta_\psi \\
            \dot{e} &= u\delta_\psi + v
        \end{align}
\end{Fancybox}

\end{document}

enter image description here

Moriambar
  • 11,466
Gonzalo Medina
  • 505,128
  • Thank you very much..and one more how cen i get middle of mdframed box (Y coordinate), i'm trying to put some extra staff on Y like here ' singleextra={\path let \p1=(P), \p2=(O) in node[fill=red,font=\color{white}] at (P|-0,0.5\y2+0.5\y1) {$\clubsuit$};} ' calculation does not work on my case

    Heres' one possible solution; the Fancybox" http://tex.stackexchange.com/questions/115576/boxed-text-between-pages/115605#115605

    – Levan Shoshiashvili Jun 14 '13 at 23:39
  • @LevanShoshiashvili and what should happen if the box has a page break? In the solution I proposed in the question you linked, no decoration is shown in this case (and as I said there, this seems a sensible choice). Do you agree with this? I mean, no decoration if a page break occurs? – Gonzalo Medina Jun 14 '13 at 23:46
  • 1
    @LevanShoshiashvili please see my updated answer showing how to add the decoration. – Gonzalo Medina Jun 14 '13 at 23:51
  • yes i know, i have seen, when box continues to another page there is no '$\clubsuit$' on 'fancytitle box' it is ok...I made this optional..i have added new mdf key to pass code to display in middle of box (similar to exercise points example , which is in documentation of mdframed). Just dont know how to get in middle of box :) ...I have to update original question or post modified code as new unswer..This is not convenient..i can not post lagre code in comments – Levan Shoshiashvili Jun 14 '13 at 23:54
  • can i post mu updated code as answer? I did this one time and it was deleted :) – Levan Shoshiashvili Jun 14 '13 at 23:55
  • @LevanShoshiashvili It would be better to edit your question and add the new code there, indicating what you need and what you have tried. – Gonzalo Medina Jun 15 '13 at 00:06
  • @GonzaloMedina: In the new version you can work with the node mdframe.east ;-) – Marco Daniel Jun 15 '13 at 15:39
  • @MarcoDaniel Ah, that's helpful. I still haven't had the time to look the new version; will do it as soon as I can. – Gonzalo Medina Jun 15 '13 at 21:08
  • I still think it woud be great to have option just use titlebox true/false option (see my original 1st post), than so many redefinitions and so on can be avoided. right? – Levan Shoshiashvili Jun 17 '13 at 22:56