# Align Text at the Top of a Minipage and Control the Vertical Space Between a Rule and the Text Above it

I have the following MWE in which I have two issues.

The first issue is that I can't align the text of the minipages at the top of each other. I have used the [t] identifier but it doesn't work. I have read the other similar questions here and all of them suggest that it should have worked.

The second issue is that I want to find a way to completely control the vertical space between the ruler and the title above it. I want to place it a little below the text but \hrule places it too close.

MWE

\documentclass{article}

\usepackage{fontspec}

\usepackage[english]{babel}

\begin{document}

\begin{center}

{\LARGE \textbf{Text Here}}

\end{center}

\vspace{1cm}

{\large Text here}

\rule{\textwidth}{1pt}

\vspace{0.5cm}

\begin{minipage}[t]{0.1\textwidth}
\begin{flushright}
Hello
\end{flushright}
\end{minipage}%
%
\hspace{1pt}
%
\begin{minipage}[t]{0.05\textwidth}
\rule{1pt}{2cm}
\end{minipage}%
%
\begin{minipage}[t]{0.80\textwidth}
Hello
\end{minipage}

\end{document}

• does your question absolutely depend on use of a non standard font? It would be easier to help if you made your test file generally usable. Most likely your issue is the use of \begin{flushright} which probably wants to be \raggedleft so as not to change the vertical alignment – David Carlisle Jan 28 '17 at 18:33
• @DavidCarlisle You are correct! I hadn't noticed I will edit my question. – Adam Jan 28 '17 at 18:34

minipage's option t does not mean top edge of the minipage but top baseline of the minipage. The baseline of a \rule is below the rule by default. But you can move the rule using the optional raise argument.

The reason for the distance between the horizontal rule and the text above is the same and again you can use the optional raise argument.

In the following example I use \ht\strutbox as (part of) the raise argument. \ht\strutbox is something like the height of a standard text line.

\documentclass{article}

\usepackage{fontspec}

\usepackage[english]{babel}

\begin{document}

\begin{center}

{\LARGE \textbf{Text Here}\par}

\end{center}

\vspace{1cm}

{\large Text here\par}

\rule[\ht\strutbox]{\textwidth}{1pt}

\vspace{0.5cm}

\begin{minipage}[t]{0.1\textwidth}
\begin{flushright}
Hello
\end{flushright}
\end{minipage}%
%
\hspace{1pt}
%
\begin{minipage}[t]{0.05\textwidth}
\rule[\dimexpr \ht\strutbox-2cm]{1pt}{2cm}
\end{minipage}%
%
\begin{minipage}[t]{0.80\textwidth}
Hello
\end{minipage}

\end{document}


BTW: I've added \par before the end of font size changing groups, because the paragraph setting is done with the font size settings that is valid at the end of the paragraph.

An alternative would be to lower the minipages to align them at the their top edges instead of their top baseline. This can be done using \raisebox:

\documentclass{article}

\usepackage{fontspec}

\usepackage[english]{babel}

\begin{document}

\begin{center}

{\LARGE \textbf{Text Here}\par}

\end{center}

\vspace{1cm}

{\large Text here\par}

\rule[\ht\strutbox]{\textwidth}{1pt}

\vspace{0.5cm}

\raisebox{\dimexpr\ht\strutbox-\height}{\begin{minipage}[t]{0.1\textwidth}
\raggedright
Hello
\end{minipage}}%
%
\hspace{1pt}
%
\raisebox{\dimexpr\ht\strutbox-\height}{\begin{minipage}[t]{0.05\textwidth}
\raggedright
\rule{1pt}{2cm}
\end{minipage}}%
%
\raisebox{\dimexpr\ht\strutbox-\height}{\begin{minipage}[t]{0.80\textwidth}
Hello
\end{minipage}}

\end{document}


In this case \height is the height of the contents of the box. The result is:

A second alternative would be to give all the minipages the same top base line:

\documentclass{article}

\usepackage{fontspec}

\usepackage[english]{babel}

\begin{document}

\begin{center}

{\LARGE \textbf{Text Here}\par}

\end{center}

\vspace{1cm}

{\large Text here\par}

\rule[\ht\strutbox]{\textwidth}{1pt}

\vspace{0.5cm}

\begin{minipage}[t]{0.1\textwidth}
\vskip -\baselineskip
\raggedright
Hello
\end{minipage}%
%
\hspace{1pt}
%
\begin{minipage}[t]{0.05\textwidth}
\vskip -\baselineskip
\raggedright
\rule{1pt}{2cm}
\end{minipage}%
%
\begin{minipage}[t]{0.80\textwidth}
\vskip -\baselineskip
Hello
\end{minipage}%

\end{document}


The minipages are top-aligned with respect to the first line of each. What makes it seem wrong is that the lower end of the line sits on the base line. So you have to lower the line below the base line.

\begin{minipage}[t]{0.05\textwidth}
\raisebox{\dimexpr-\height+1.5ex}{\rule{1pt}{2cm}}
\end{minipage}%


Regarding the second question, I'm not sure that I understand the issue. But you can e.g. control the distance between text and horizonal rule using

{\large Text here}\\[-2ex]
\rule{\textwidth}{1pt}


Replace -2ex whatever distance you need.