1

We have a problem concerning the vertical alignment of a mdframed followed by minipages. Latex put not the objects right after each other. It distributes them over the whole page and maximizes the vertical space between them. The following code shows the problem (after the mdframed). Does anybody know how to get the next minipage just next to the end of the mdframed?

Thanks!

Volker

\documentclass[a4paper,12pt, twoside, bibliography=totocnumbered]{scrreprt}

\usepackage{ngerman}
\usepackage[utf8]{inputenc}
\usepackage{xspace}
\usepackage{mdframed}
\usepackage{xifthen}
\usepackage{enumitem} 
\usepackage{xcolor}
\usepackage{lipsum}

\usepackage[math]{iwona}

\textwidth165mm
\setlength{\marginparsep}{0cm}
\setlength{\marginparwidth}{1.5cm}
\setlength{\oddsidemargin}{-0.5cm}
\setlength{\evensidemargin}{-1.5cm}
\setlength{\topmargin}{-2cm}
\setlength{\textheight}{25cm}

\mdfdefinestyle{plainstyle}{%
    backgroundcolor=lightgray,
    hidealllines=true,
}

\setcounter{secnumdepth}{1}
\setcounter{tocdepth}{1}

\newcommand{\negation}[1]{\underline{\textbf{#1}}}
\newcommand{\highlightened}[1]{\textit{#1}}
\newcommand{\examIntroduction}[0]{}
\newcommand{\sectionDescription}[0]{}
\newcommand{\itemVignette}[0]{}
\newcommand{\questionVignette}[1]{\ifthenelse{\isempty{#1}}{#1}{#1\vspace{3mm}}}
\newcommand{\questionText}[0]{}

\newcounter{itemobject}
\renewcommand\theitemobject{\arabic{itemobject}}

\newcounter{questionobjectcase}[itemobject]
\renewcommand\thequestionobjectcase{
\stepcounter{questionobject}
\hfill\textbf{\arabic{questionobject}}\ \ \newline
{\normalfont\footnotesize{\ \ (Fall \arabic{itemobject})}}
}

\newcounter{questionobject}
\renewcommand\thequestionobject{\arabic{questionobject}}

\newcommand\testquestion{
  \begin{minipage}[t]{15mm}
    \begin{flushright} 
       \textbf{\stepcounter{questionobject} 
       \thequestionobject} \ \hspace{3mm}
    \end{flushright} 
   \end{minipage}
   \hfill
   \begin{minipage}[t]{15cm}                    
        \questionVignette{The quick brown fox jumps over the lazy dog. Jeder wackere Bayer vertilgt bequem zwo Pfund Kalbshaxen. Heavy boxes perform waltzes and jigs. The five boxing wizards jump quickly. Five quacking Zephyrs jolt my wax bed. A quick movement of the enemy will jeopardize six gunboats. Portez ce vieux whisky au juge blond qui fume. Zornig und gequält rügen jeweils Pontifex und Volk die maßlose bischöfliche Hybris. Die heiße Zypernsonne quälte Max und Victoria ja böse auf dem Weg bis zur Küste.}\par
         \questionText{What is the correct answer?}\par

        \begin{enumerate}[label=(\Alph*)]
    \item  Nothing
    \item  Everything
    \item  Nearly nothing
    \item  All of them
    \item  I don't know
        \end{enumerate}
        \vspace{10mm}
   \end{minipage}
 }

\begin{document}

\testquestion
\testquestion
\testquestion

\pagebreak
\begin{addmargin}{1.5cm}
    \setcounter{questionobjectcase} {0}
    Fallstudie Nr. \stepcounter{itemobject} 
    \theitemobject
    \begin{mdframed}[style=plainstyle,userdefinedwidth=15cm]
        \itemVignette{\lipsum}  
    \end{mdframed}
\end{addmargin}

\testquestion
\testquestion
\testquestion

\end{document}
  • Use \raggedbottom. And I would advise you to use tcolorbox instead of mdframed -- much better and more stable. – Ulrike Fischer Jul 27 '17 at 7:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.