4

There are some very advanced answer that I can't figure out how to adapt to this situation.

When I do the following the text in the second column does get vertically centred for some reason.

Question

Can someone figure out how vertically centre both columns?

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{fontawesome5}
\begin{document}

\begin{tabular}{cl} {\huge \faIcon{envelope}} \hspace{0.5em} & xxx\\ {\huge \faIcon{phone-square-alt}} \hspace{0.5em} & xxx\\ {\huge \faIcon{trophy}} \hspace{0.5em} & xxx y.o.\\ {\huge \faIcon{map-marker-alt}} \hspace{0.5em} & xxx \end{tabular}

\end{document}

Update

The problem seams to be related to font awesome?

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{fontawesome5}
\usepackage{tabularray}
\begin{document}

\begin{tblr}{Q[c,m]Q[l,m]]} \hline {\huge \faIcon{envelope}} \hspace{0.5em} & xxx\\ \hline {\huge \faIcon{phone-square-alt}} \hspace{0.5em} & xxx\\ {\huge \faIcon{trophy}} \hspace{0.5em} & xxx y.o.\\ {\huge \faIcon{map-marker-alt}} \hspace{0.5em} & xxx \end{tblr}

\end{document}

  • While the accepted answer in the question you linked question looks complicated, it directly links to another answer using tabularray package which should be very simple: https://tex.stackexchange.com/questions/7208/how-to-vertically-center-the-text-of-the-cells/611601#611601 – user202729 Feb 03 '23 at 15:09
  • @user202729 I wish I could understand the example... – Sandra Schlichting Feb 03 '23 at 15:11
  • 1
    You should be able to easily find the documentation of that LaTeX package on CTAN to look up the options passed to the environment. – user202729 Feb 03 '23 at 15:14
  • @user202729 Great documentation indeed. The problem seams to be related to font awesome? Now updated OP. – Sandra Schlichting Feb 03 '23 at 15:31
  • This is unexpected. Anyway it's probably the same reason as https://tex.stackexchange.com/a/653498/250119...? – user202729 Feb 03 '23 at 16:38
  • 1
    The problem isn't font awesome per se but a {\huge } character in a cell and a normal character in the other cell, where both are on baseline… https://tex.stackexchange.com/a/673903/23418 I would go with \raisebox{}{} trials too https://tex.stackexchange.com/a/673871/23418 – gildux Feb 04 '23 at 02:04

4 Answers4

5

This can be achieve by using array.sty and the column format m. and the MWE is:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{fontawesome5}
\usepackage{array}
\begin{document}

\begin{tabular}{m{5pc}m{5pc}}%change the value as you like {\huge \faIcon{envelope}} \hspace{0.5em} & xxx\\ {\huge \faIcon{phone-square-alt}} \hspace{0.5em} & xxx\\ {\huge \faIcon{trophy}} \hspace{0.5em} & xxx y.o.\\ {\huge \faIcon{map-marker-alt}} \hspace{0.5em} & xxx \end{tabular}

\end{document}

enter image description here

MadyYuvi
  • 13,693
5

A possible solution with a TikZ matrix:

\documentclass{article}
%\usepackage[utf8]{inputenc}%no more needed
\usepackage{fontawesome5}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix[
    matrix of nodes,
    column 1/.style={nodes={font=\huge, anchor=center}},
    column 2/.style={nodes={anchor=west}}
    ]
    {
    \faIcon{envelope} &[.5em] xxx\\
    \faIcon{phone-square-alt} & xxx\\
    \faIcon{trophy} & xxx y.o.\\
    \faIcon{map-marker-alt}  & xxx\\
    };
\end{tikzpicture}
\end{document}

enter image description here

CarLaTeX
  • 62,716
4

Vertical centering is not well defined when a single row of text is concerned: what do you take as vertical center? With respect to lowercase letters? Or those with neither ascenders nor descenders? Or those with both?

On the other hand, fontawesome symbols have different ideas of where they sit on:

\_\faIcon{envelope}\_\faIcon{phone-square-alt}\_\faIcon{trophy}\_\faIcon{map-marker-alt}\_

enter image description here

I redefined the \_ command for this purpose in order to show precisely the baseline at its top edge.

An answer might be to adopt as vertical center the math axis, where fraction lines sit on. As the picture shows, the math axis is at the center of the capital X.

\documentclass{article}
%\usepackage[utf8]{inputenc}
\usepackage{fontawesome5}

\newcommand{\myfa}[1]{% $\vcenter{\hbox{\huge\faIcon{#1}}}$% }

\begin{document}

\begin{tabular}{c@{}cl} $\frac{\quad}{}$& \myfa{envelope}\hspace{0.5em} & Xyz\\ $\frac{\quad}{}$& \myfa{phone-square-alt}\hspace{0.5em} & Xyz\\ $\frac{\quad}{}$& \myfa{trophy}\hspace{0.5em} & Xyz y.o.\\ $\frac{\quad}{}$& \myfa{map-marker-alt}\hspace{0.5em} & Xyz \end{tabular}

\end{document}

enter image description here

egreg
  • 1,121,712
3

Not a nice solution, but you could manually raise the text in the second column a bit:

\documentclass{article}

\usepackage{fontawesome5} \usepackage{xcolor} \usepackage{tabularray} \usepackage{graphicx}

\begin{document}

\begin{tblr}{ colspec={c|[1cm,white]l}, column{1}={font=\huge}, } \faIcon{envelope} & \raisebox{1.4ex}{xxx}\ \faIcon{phone-square-alt} & \raisebox{1.4ex}{xxx}\ \faIcon{trophy} & \raisebox{1.4ex}{xxx y.o.}\ \faIcon{map-marker-alt} & \raisebox{1.4ex}{xxx}\ \end{tblr}

\end{document}

enter image description here

(the redlines are just for visualisation)