[Tex/LaTex] How to choose which sides of the border to draw in a `framebox`

boxesframed

If, for example, you only want to draw the top and bottom border of a box, or perhaps the left and bottom only, is there a simple package to do this or must one resort to using tables or heavy-weight drawing tools like tikz?

Best Answer

The mdframed package has what you want. Here is a MWE that demonstrates the borders you described in three new environments.

There are many other options available- see the documentation for more details and examples.

screenshot

\documentclass{article}
\usepackage{mdframed}
\usepackage{lipsum}

% all 4 borders
\newmdenv{allfour}

% just top and bottom
\newmdenv[leftline=false,rightline=false]{topbot}

% just left and bottom
\newmdenv[topline=false,rightline=false]{leftbot}

\begin{document}

\subsection*{all four borders}
\begin{allfour}
\lipsum[1]
\end{allfour}

\subsection*{top and bottom}
\begin{topbot}
\lipsum[2]
\end{topbot}

\subsection*{left and bottom}
\begin{leftbot}
\lipsum[3]
\end{leftbot}
\end{document}