4

How can I make the vertical rule as long as the height of the minipage next to it? I don't want to have to test manually the height argument and find the one that fits.

MWE

\documentclass{article}

\usepackage{fontspec}

\usepackage[english]{babel}

\begin{document}

\begin{minipage}[t]{0.1\textwidth}
\begin{flushright}
Hello
\end{flushright}
\end{minipage}%
%
\hspace{1pt}
%
\begin{minipage}[t]{0.05\textwidth}
\raisebox{\dimexpr-\height+1.5ex}{\rule{1pt}{3cm}}
\end{minipage}%
%
\begin{minipage}[t]{0.80\textwidth}
Hello
\end{minipage}

\end{document}
5

You can use the low level \vrule command:

\documentclass{article}

\begin{document}

\mbox{\vrule width 1pt \hspace{3pt}%
  \begin{minipage}[t]{0.80\textwidth}
  Hello\\
  Here\\
  is\\
  a rule
  \end{minipage}%
}

\end{document}

If height and depth are not specified, the rule adjusts itself to the height and depth of the enclosing box.

enter image description here

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.