8

How do I align the table with contact info to the top of the page? My best try is this:

\documentclass[draft]{article}

\renewcommand{\familydefault}{\sfdefault}

\usepackage[showframe,margin=3cm]{geometry}
\usepackage{blindtext,booktabs,cmap,hyperref,multirow,tabularx}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\setlength\parindent{0pt}

\begin{document}

\pagestyle{empty}

%{\bfseries\LARGE Egor Tensin}\\
%\begin{flushright}
%\end{flushright}

\begin{minipage}[t]{.4\textwidth}
{\bfseries\LARGE John Smith}\\
\blindtext
\end{minipage}
\hfill
\begin{minipage}[t]{.5\textwidth}
\begin{tabular}[t]{>{\itshape}rl}
\toprule
Email:& \href{mailto:John.Smith@gmail.com}{\ttfamily John.Smith@gmail.com} \\
\midrule
Tel.:& +0\,(000)\,00-00-000 \\
\midrule
Address:& 221B Baker Street \\
& London, England \\
\bottomrule
\end{tabular}\\
\blindtext[2]
\end{minipage}

\end{document}

and see how the tabular is aligned to the bottom of the "John Smith" line? How do I align it to the top of the minipage?

ShreevatsaR
  • 45,428
  • 10
  • 117
  • 149

3 Answers3

8

The boxes are aligned on their top items, but that is text in one case and the rule in the other. array package (which you are implictly loading) defines \firsthline for exactly this case so you could go

\begin{minipage}[t]{.5\textwidth}
\begin{tabular}[t]{>{\itshape}rl}
%\toprule
\firsthline

But if you want to stick with the heavier booktabs toprule then you can space up by the amount of space that takes:

\begin{minipage}[t]{.5\textwidth}
\vspace*{-\dimexpr\baselineskip+\heavyrulewidth+\abovetopsep\relax}
\begin{tabular}[t]{>{\itshape}rl}
\toprule
%\firsthline
David Carlisle
  • 757,742
0

A quick go-through the "Related Questions" section gave me this quick & dirty solution: adding \vspace{0pt} at the beginning of minipages does the trick, though adding some vertical space and not being elegant nor idiomatic. David's answer is much better anyway.

0

If you use {NiceTabular} of nicematrix instead of {tabular}, you will have directly the expected output.

\documentclass[draft]{article}

\renewcommand{\familydefault}{\sfdefault}

\usepackage[showframe,margin=3cm]{geometry} \usepackage{blindtext,booktabs,cmap,hyperref,multirow,tabularx} \usepackage[T2A]{fontenc} \usepackage[english]{babel} \setlength\parindent{0pt}

\usepackage{nicematrix}

\begin{document}

\pagestyle{empty}

\begin{minipage}[t]{.4\textwidth} {\bfseries\LARGE John Smith}\ \blindtext \end{minipage} \hfill \begin{minipage}[t]{.5\textwidth} \begin{NiceTabular}[t]{>{\itshape}rl} \toprule Email:& \href{mailto:John.Smith@gmail.com}{\ttfamily John.Smith@gmail.com} \ \midrule Tel.:& +0,(000),00-00-000 \ \midrule Address:& 221B Baker Street \ & London, England \ \bottomrule \end{NiceTabular}\ \blindtext[2] \end{minipage}

\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

Output of the above code

F. Pantigny
  • 40,250