I want to create a minipage like the one shown in the picture. Any ideas how to do it? Thanks!
[Tex/LaTex] Minipage with vertical and horizontal lines
minipage
Related Solutions
Besides measuring box heights and according manual placement you could use two tabulars
. Compared to nested minipages
, you do not have to specify any widths for the outer environment with this approach. Further packages are not required; however, if desirable e.g. for the "aa" and "zz" text parts, you could make use of advanced table features such as automatic-width X
columns.
Proper bottom alignment of the two tables is sensitive to the insertion of a space, e.g. [0pt]
, after the line breaks (alternatively, a rule may be used).
The tables insert some additional horizontal space in the current setting. This space can however be removed by placing @{}
before/after each column in the column definitions and by removing the line break between the tables.
\documentclass{article}
\usepackage{lipsum}
\usepackage[showframe,showcrop]{geometry}
\begin{document}
\section{Section 1}
\rule{\textwidth}{.5pt}
\begin{tabular}[b]{lll}
aa
& \fbox{\begin{minipage}[t]{100pt}Box 1\end{minipage}}
& \fbox{\begin{minipage}[t]{150pt}\lipsum[11]\end{minipage}}
\\[0pt]
\end{tabular}
\begin{tabular}[b]{ll}
\fbox{\begin{minipage}[b]{50pt}..... Box 3\end{minipage}}
& zz
\\[0pt]
\end{tabular}
\\\rule[\baselineskip]{\textwidth}{.5pt}
\end{document}
The posted code does not show the effect that you ask about, I changed the minipage width in the example below so the second example shows the problem.
The spurious white line is not caused by the \vspace
but by the extra inter-word space that you added. You can avoid adding the space by commenting out the end of line or (better) always add a blank line before a \vspace
so that it is added in vertical mode.
\documentclass{article}
\begin{document}
When "vspace" is not inserted:
\fbox{
\begin{minipage}{2.5cm}
\raggedright
AAA CD/ BB-2
\end{minipage}
}
\vspace{30pt}
When "vspace" is inserted to give vertical margin in the minipage:
\fbox{
\begin{minipage}{2.55cm}
\vspace{2pt}
\raggedright
AAA CD/ BB-2
\vspace{2pt}
\end{minipage}
}
\fbox{
\begin{minipage}{2.55cm}
\vspace{2pt}
\raggedright
AAA CD/ BB-2%
\vspace{2pt}
\end{minipage}
}
\fbox{
\begin{minipage}{2.55cm}
\vspace{2pt}
\raggedright
AAA CD/ BB-2
\vspace{2pt}
\end{minipage}
}
\end{document}
Best Answer
Here's one possibility admitting page breaks using
tcolorbox
:And with
mdframed
: