13

I am creating a table containing several foreign names with diacritical marks in them, and it seems to me that they ruin the vertical alignment, as they are too close to the top horizontal line. How should I center these correctly? Is the fictional acronym O\'O\"O\H{O} correctly rendered from overshooting point of view, or should one bump the leading letter O a bit higher?

\documentclass{article}
\begin{document}
\begin{table}[!h]
\begin{tabular}{|c|c|c|c|c|c|}
\hline
\"Ostersund & \AA m\aa l & Oxel\"osund & Alings\aa s & \'Orlaith &O\'O\"O\H{O}\\
\hline
\end{tabular}
\end{table}
\end{document}

enter image description here

3
  • Using booktabs package with \toprule instead of \hline works. May 2, 2016 at 21:46
  • I have checked, and -- in the way you described -- it does not work. Now the vertical bars are not tall enough.
    – Matsmath
    May 2, 2016 at 21:53
  • 2
    With booktabs it works without the vertical rules, which that package discourages. For every table-related question here, someone will tell you to use booktabs and avoid vertical rules, even though that's not always the best answer. But booktabs does implement better spacing around its horizontal rules. May 2, 2016 at 21:56

4 Answers 4

10

I think the best way to proceed is to stop using \hline -- and, while you're at it, ditch all vertical bars -- and to use the line-drawing macros of the booktabs package. For the table at hand, \toprule and \bottomrule should be used.

If, for some reason, you simply must use vertical bars (and hence can't use \toprule and \bottomrule), I suggest you load the array package and set the length of \extrarowheight to something like 2pt or 3pt.

enter image description here

\documentclass{article}
\usepackage{array,booktabs}
\begin{document}

%% original form
\begin{tabular}{|c|c|c|c|c|c|}
\hline
\"Ostersund & \AA m\aa l & Oxel\"osund & Alings\aa s & \'Orlaith & O\'O\"O\H{O}\\
\hline
\end{tabular}

\medskip
%% with rule-drawing macros of the booktabs package
\begin{tabular}{cccccc}
\toprule
\"Ostersund & \AA m\aa l & Oxel\"osund & Alings\aa s & \'Orlaith & O\'O\"O\H{O}\\
\bottomrule
\end{tabular}


\medskip
%% with \extrarowheight set to 3pt
\setlength\extrarowheight{3pt}
\begin{tabular}{|c|c|c|c|c|c|}
\hline
\"Ostersund & \AA m\aa l & Oxel\"osund & Alings\aa s & \'Orlaith & O\'O\"O\H{O}\\
\hline
\end{tabular}

\end{document}
10

The problem is not in diacritics, it is in LaTeX tables. You can give rows some vertical padding with the cellspace package, which ensure a minimal vertical distance between a cell and the above and below rules.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{array, cellspace}
\setlength\cellspacetoplimit{3pt}
\setlength\cellspacebottomlimit{3pt}

\begin{document}

\begin{table}[!h]
\begin{tabular}{|*{6}{Sc|}}
\hline
\"Ostersund & \AA m\aa l & Oxel\"osund & Alings\aa s & \'Orlaith &O\'O\"O\H{O}\\
\hline
\end{tabular}
\end{table}

\end{document} 

enter image description here

7

Insert a large \strut.

\documentclass{article}
\begin{document}
\begin{table}[!h]
\begin{tabular}{|c|c|c|c|c|c|}
\hline
{\Large\strut}\"Ostersund & \AA m\aa l & Oxel\"osund & Alings\aa s & \'Orlaith &O\'O\"O\H{O}\\
\hline
\end{tabular}
\end{table}
\end{document}

enter image description here

2
  • That's clever! I will look into this strutness.
    – Matsmath
    May 2, 2016 at 21:56
  • 1
    Since \strut has both height and depth, it'll also increase the amount of whitespace below the baseline; this may or may not be desirable. Can you suggest how to create a top-strut (only height, but no depth) to handle the typographic issue?
    – Mico
    May 2, 2016 at 21:57
2

OPTION 1: Row specific padding

One can add a \stackgap to a given element of the line, which pads the element vertically by the amount of the optional argument (default 3pt). The MWE below shows 3 rows that have been padded with 1pt, 3pt, and 5pt, respectively.

\documentclass{article}
\usepackage{stackengine}
\begin{document}
\begin{table}[!h]
\begin{tabular}{|c|c|c|c|c|c|}
\hline
\addstackgap[1pt]{\"Ostersund} & \AA m\aa l & Oxel\"osund & Alings\aa s & \'Orlaith &O\'O\"O\H{O}\\
\hline
\addstackgap[3pt]{\"Ostersund} & \AA m\aa l & Oxel\"osund & Alings\aa s & \'Orlaith &O\'O\"O\H{O}\\
\hline
\addstackgap[5pt]{\"Ostersund} & \AA m\aa l & Oxel\"osund & Alings\aa s & \'Orlaith &O\'O\"O\H{O}\\
\hline
\end{tabular}
\end{table}
\end{document}

enter image description here

OPTION 2: Uniform (and automatic) padding

Another way, if the same padding is wanted for each row, is to use tabularx and the >{} feature to automatically pad the contents, specifically here,

>{\addstackgap[2pt]{\vphantom{\"Xg}}}

which adds a 2pt buffer to something the height and depth of \"Xg, which was chosen to represent the vertical extent of typical diacritically modified text:

\documentclass{article}
\usepackage{stackengine}
\usepackage{tabularx}
\begin{document}
\begin{table}[!h]
\begin{tabular}{|>{\addstackgap[2pt]{\vphantom{\"Xg}}}c|c|c|c|c|c|}
\hline
\"Ostersund & \AA m\aa l & Oxel\"osund & Alings\aa s & \'Orlaith &O\'O\"O\H{O}\\
\hline
\"Ostersund & \AA m\aa l & Oxel\"osund & Alings\aa s & \'Orlaith &O\'O\"O\H{O}\\
\hline
\"Ostersund & \AA m\aa l & Oxel\"osund & Alings\aa s & \'Orlaith &O\'O\"O\H{O}\\
\hline
\end{tabular}
\end{table}
\end{document}

enter image description here

3
  • How do I know how much padding is needed? Or is this a trial-and-error approach?
    – Matsmath
    May 3, 2016 at 12:14
  • 1
    @Matsmath It is an aesthetic preference. So find a value you like and stick with it. May 3, 2016 at 12:15
  • @Matsmath I have added a 2nd option, as well. May 3, 2016 at 12:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .