Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.
\documentclass{article}
\usepackage{tabularx}
\usepackage{tikz}

\begin{document}

\begin{tabularx}{\linewidth}{c|X}
\begin{tikzpicture}[
    scale=.6,
    every node/.style={scale=.6}
    ]
     \path[draw] (0,0) rectangle 
        +(3,2) node [pos=.5] {rectangle}
        +(3,1.5) node[anchor=east] (a)  {A}
        +(3,0.5) node[anchor=east] (b) {B};
\end{tikzpicture}
& 
 \begin{tabular}{l}
 This line is not aligned vertically top\\
 This is another line below the first one
 \end{tabular}
\end{tabularx}

\end{document}

compiled example

In this example a small tikz picture changes the baseline of the text so that the next cell starts at the bottom of the cell. i would like the baseline to stay where it was and have the tikz picture insert itself without changing it. that way my subsequent inputs would stay at the top of the cell.

How can i make my second cell align vertically topside?

share|improve this question
2  
the picture hasn't moved the baseline. It has its baseline at the bottom and the tabular (as you haven't use [t]) has its baseline through the centre, so when these two items are placed on the baseline of the outer tabularx, the bottom of the tikzpicture aligns with the centre of the tablular –  David Carlisle Feb 25 '13 at 14:02
    
and where would that '[t]' go? I tried to pass a '[t]' to the tabular inside the tabularx but it did not change anything. –  Johannes Feb 25 '13 at 14:22
add comment

1 Answer

up vote 6 down vote accepted

enter image description here

If you just add [t] to the tabular, initially it will move down as the top row will align with the bottom of the picture. Then you want to put the baseline of the picture somewhere other than the bottom, eg the baseline of the node a.:

\documentclass{article}
\usepackage{tabularx}
\usepackage{tikz}

\begin{document}

\begin{tabularx}{\linewidth}{c|X}
\begin{tikzpicture}[
baseline={(a.base)},
    scale=.6,
    every node/.style={scale=.6}
    ]
     \path[draw] (0,0) rectangle 
        +(3,2) node [pos=.5] {rectangle}
        +(3,1.5) node[anchor=east] (a)  {A}
        +(3,0.5) node[anchor=east] (b) {B};
\end{tikzpicture}
& 
 \begin{tabular}[t]{l}
 This line is not aligned vertically top\\
 This is another line below the first one
 \end{tabular}
\end{tabularx}

\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.