4

How can I either remove the space after the first hline of the right tabular (the second tabular in the following code) or if that is not possible, what kind of value do I have to pass to the trim-parameter of adjustbox (e.g. {valign=T, trim=0 \parskip} or something like that) in order to get rid of this space? Note that I don't care about the hline. It's just here to show you, what kind of space I want to remove.

Thank you!

\documentclass{scrartcl}

\usepackage{adjustbox}

\begin{document}
\adjustbox{valign=T}{\begin{tabular}[t]{@{}l}\hline
\Huge X1\\\\
\tiny X2
\end{tabular}}
\adjustbox{valign=T}{\begin{tabular}[t]{r@{}}\hline
X1\\\\X2
\end{tabular}}
\end{document}
3

A workaround (you can remove the \adjustboxes):

\documentclass{scrartcl}

\usepackage{adjustbox}

\begin{document}
\adjustbox{valign=T}{\begin{tabular}[t]{@{}l}
\hline
\Huge X1\\\\
\tiny X2
\end{tabular}}%
\adjustbox{valign=T}{\begin{tabular}[t]{r@{}}
\hline
\\[-3.31ex]X1\\\\X2
\end{tabular}}
\end{document} 

enter image description here

  • The two \adustbox instructions don't do anything, or do they? AFAICT, all the work is done by the instruction \\[-3.31ex], or am I missing something? – Mico Feb 16 '14 at 9:46
  • @Mico Yes, as I said in the answer they can be removed. – karlkoeller Feb 16 '14 at 10:41
2

Not a full solution, but some (hopefully helpful) comments about the lack of action of the \adjustbox instruction in the present case and some suggestions for a workaround.

In the example code you've provided, it's important to realize that the fact that the upper edge of the "Huge" X in the left-hand tabular happens to touch its \hline is pure coincidence; it is not caused by the presence of the \adjustbox{valign=T}{...} instruction. You can check this out for yourself by leaving off the \adjustbox instruction.

So, what to do to get the desired alignment of the upper edge of the (normal-sized) letter "X" with the horizontal line? I can't come up with an elegant solution, but only with two suggestions for a brute-force workaround: (a) the "TeX primitive commands" \raise and \hbox and (b) the command \raisebox that's provided by the graphicx package. By how much the material should be raised will depend, naturally, largely on the size of the material. For the case of "X1" in a document where the natural fontsize is 11pt, 2pt seems to be the correct amount.

Incidentally, shifting the first row of the tabular does not affect the baseline of the second row. If you need to displace vertically the entire tabular environment, you should encase it in a \raise...\hbox{...} instruction.

enter image description here

\documentclass[11pt]{scrartcl}
\usepackage{graphicx} % provides \raisebox macro
\begin{document}
% 1st tabular
\begin{tabular}[t]{@{}l}
  \hline
   {\Huge X1}\\ X2
\end{tabular}
% 2nd tabular
\begin{tabular}[t]{r@{}}
  \hline
  \raise2pt\hbox{X1}\\ X2 % \raise and \hbox are "primitive" commands
\end{tabular}
% 3rd tabular
\begin{tabular}[t]{r@{}}
  \hline
  \raisebox{2pt}{X1}\\ X2
\end{tabular}
\end{document}

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.