1

I need to align table cells content vertically. To do it in normal human definition (not in latex base line) and automaticly, i need to know in which cell in the row text is smaller (takes verticaly smaller space).

Is is possible to know actual height of the text in the cell?

6
  • 2
    \heightof{<argument>}? – azetina Apr 11 '17 at 3:33
  • 1
    can you please show an example? how to take \heightof some cell? i shoud mark this cell and then pass the marker as argument? i'm not close with the latex syntax ) – Mira Apr 11 '17 at 3:36
  • 2
    I can help you better if you provide a minimal working example showcasing your attempt as to what you want to achieve and probably a diagram illustrating the end result. You can search here at TeX.SX for cell alignment. There should be something around that can help you. – azetina Apr 11 '17 at 3:38
  • I understand cell aligment. in this question was my attempts tex.stackexchange.com/questions/363976/… and now i can align manually, looking with my eyes at the result. But i need to make it automaticly, so it's nesessary to know which cell is higher then another. – Mira Apr 11 '17 at 3:43
  • 1
    Try something like \newlength{\mylength}\setlength{\mylength}{\heightof{<argument>}} or you can use \settoheight. Now with \mylength defined you can put it as an argument to heights or widths in your examples. Here is link to the definition of these lengths: forkosh.com/latex/ltx-86.html – azetina Apr 11 '17 at 3:51
4

Your question is still a bit unclear. But if you really only want to align everything at the top you should be able to do it with p-columns and a \vspace{0pt} at the start everywhere:

\documentclass{book}
\usepackage{graphicx}
\usepackage{array,tikz}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash\vspace{0pt}}p{#1}}

\begin{document}

xxx\tikz[overlay]\draw[red](0,0)--++(15,0);%
\begin{tabular}[t]{L{2cm}L{2cm}L{2cm}L{2cm}L{2cm}} 
 \includegraphics[width=\linewidth, height=25pt]{example-image} &
 \includegraphics[width=\linewidth, height=150pt]{example-image}&
 \tikz[overlay]\draw[blue](0,0)--++(5,0);%
              bllb \par bllb &
 \huge blblb & 
 xxxx 
\end{tabular}

\end{document}

enter image description here

Instead of \vspace{0pt} you can also use a negative value. Then it will work to some extend also with l-columns:

\documentclass{book}
\usepackage{graphicx}
\usepackage{array,tikz}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash\vspace{-\ht\strutbox}}p{#1}}

\begin{document}

xxx
\tikz[overlay]\draw[red](0,0)--++(15,0);%
 \begin{tabular}[t]{lL{2cm}L{2cm}L{2cm}L{2cm}}
 ly &
 \includegraphics[width=\linewidth, height=25pt]{example-image} &
 \includegraphics[width=\linewidth, height=150pt]{example-image}&
 \tikz[overlay]\draw[blue](0,0)--++(5,0);%
              bllb \par bllb &
 \huge BBB xxxx
\end{tabular}

\end{document}

enter image description here

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.