2

Code:

\documentclass[12pt]{article}
\usepackage[framemethod = tikz]{mdframed}
\usepackage{enumitem}
\usepackage[margin=1in]{geometry} 
\begin{document} 
    \begin{mdframed}
%       \section*{Objective:}
        \begin{itemize}
            \item To become familiar with the measurements in electric circuits
            \item To determine the equivalent resistances of series and parallel combinations
            \item To use Kirchhoff's laws
        \end{itemize}
    \end{mdframed}
    \begin{mdframed}
        \section*{Objective:}
        \begin{itemize}
            \item To become familiar with the measurements in electric circuits
            \item To determine the equivalent resistances of series and parallel combinations
            \item To use Kirchhoff's laws
        \end{itemize}
    \end{mdframed}
\end{document}

Output: enter image description here

As we can see, the section header produces extra whitespace between itself and the top of the mdframed box. How much whitespace does it produce, and how to remove it?

2

Here is an alternative using a customized box with the help of the tcolorbox package:

enter image description here

\documentclass[12pt]{article}
\usepackage{enumitem}
\usepackage{tcolorbox}

\newtcolorbox{mybox}
{
  colback  = white,
  sharp corners, 
  boxrule=1pt
}
\usepackage[margin=1in]{geometry} 
\begin{document} 
    \begin{mybox}
%       \section*{Objective:}
        \begin{itemize}
            \item To become familiar with the measurements in electric circuits
            \item To determine the equivalent resistances of series and parallel combinations
            \item To use Kirchhoff's laws
        \end{itemize}
    \end{mybox}
    \begin{mybox}
        \section*{Objective:}
        \begin{itemize}
            \item To become familiar with the measurements in electric circuits
            \item To determine the equivalent resistances of series and parallel combinations
            \item To use Kirchhoff's laws
        \end{itemize}
    \end{mybox}
\end{document}
5
  • So does \boxrule = 1pt essentially get rid of the whitespace between section and the top?
    – Superman
    Jun 13 '20 at 21:40
  • On a side note, while the white space on top is gone, more side margins are added within the box i.e. the section moved slightly to the right. I was wondering If there was a way to only get rid of the top whitespace, but not change any horizontal spacing between the text and the vertical edges.
    – Superman
    Jun 13 '20 at 21:42
  • 1
    @Superman: boxrule=1pt just sets the width of the actual line to 1pt.
    – leandriis
    Jun 13 '20 at 21:43
  • 1
    Regarding the horizotal spacing: Probably \newtcolorbox{mybox} { colback = white, sharp corners, boxrule=1pt, left=2mm, right=2mm } is closer to the desired output?
    – leandriis
    Jun 13 '20 at 21:46
  • Looks about it! Thank you!
    – Superman
    Jun 13 '20 at 23:32

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.