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}
12
  • I know there are several solutions for shadows and shading, but I need it with mdframed theorems for exercises and solutions splitted across pages. I guess i nedd 'addextra' commands to add exercise points on frame title, right? Commented Jun 14, 2013 at 16:14
  • You can just add your comment to your OP.
    – dustin
    Commented Jun 14, 2013 at 16:24
  • 2
    You are overriding the shadow. Comment out the lines outerlinewidth=1em and outerlinecolor=white and you'll see the required shadow. Why are you using those options? Commented Jun 14, 2013 at 20:10
  • 1
    Use the shadowcolor key, adding to the options something like shadowcolor=red,. Commented Jun 14, 2013 at 20:41
  • 2
    @LevanShoshiashvili I've provided an answer below. Sorry to bother you, but I noticed that even you have up-voted answers to your questions, you still haven't accepted any answers (voting and accepting are two different actions). Please consider (after a sensible wait) to accept the answers that you think best solved your problems; in case of doubt, please see How do you accept an answer?. Commented Jun 14, 2013 at 23:29

1 Answer 1

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

9
  • 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" tex.stackexchange.com/questions/115576/boxed-text-between-pages/… Commented Jun 14, 2013 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? Commented Jun 14, 2013 at 23:46
  • 1
    @LevanShoshiashvili please see my updated answer showing how to add the decoration. Commented Jun 14, 2013 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 Commented Jun 14, 2013 at 23:54
  • can i post mu updated code as answer? I did this one time and it was deleted :) Commented Jun 14, 2013 at 23:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .