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.

In this MWE, I can put a minimu size by hand, but how determine it automaticaly: let say max width of the two nodes + 4pt on each side ?

enter image description here

\documentclass[french]{article}
\usepackage{tikz}

\pgfkeys{/tikz/.cd,
    BLS/.store in=\BLS,
    BLS=\baselineskip
    }

\begin{document}

\tikzset{%
    TDPnode/.style={outer sep=0pt,inner sep=1pt,
                                minimum height=\BLS,draw},
    TDPetq/.style={TDPnode,anchor=north east},
    }

\begin{tikzpicture}[yscale=-1, 
    TDPetq/.append style={minimum width=1.5cm}
    ]

\node[TDPetq] (A0) at (0,0) {angle (degree)} ; 
\node[TDPetq] (B0) at (0,\BLS) {temps (h)} ; 

\end{tikzpicture}

\end{document}
share|improve this question

1 Answer 1

up vote 4 down vote accepted

Does it helps? The idea was taken from Roelof's answer to How to right align a table in a tikz picture and joined with Caramdir's answer to Why can't I use max() here?

\documentclass[french]{article}
\usepackage{tikz}

\pgfkeys{/tikz/.cd,
    BLS/.store in=\BLS,
    BLS=\baselineskip
    }

\begin{document}

\tikzset{%
    TDPnode/.style={outer sep=0pt,inner sep=1pt,
                                minimum height=\BLS,draw},
    TDPetq/.style 2 args={TDPnode,anchor=north east,
             minimum width={max(width("#1"), width("#2"))+8pt}},
    }

\begin{tikzpicture}[yscale=-1]
\node[TDPetq={angle (degree)}{temps (h)}] (A0) at (0,0) {angle (degree)} ; 
\node[TDPetq={angle (degree)}{temps (h)}] (B0) at (0,\BLS) {temps (h)} ; 

\begin{scope}[xshift=5cm]
\node[TDPetq={short}{second much longer}] (A0) at (0,0) {angle (degree)} ; 
\node[TDPetq={short}{second much longer}] (B0) at (0,\BLS) {temps (h)} ; 
\end{scope}
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
    
Thank's I knew max but not width ... ;-( –  Tarass Apr 28 at 16:27
    
Doesn't work for \pgfmathsetlengthmacro{\TDPew}{max(width("#1"),width("#2")) –  Tarass Apr 28 at 17:31
    
@Tarass: I've rewritten my answer. Is it better now? –  Ignasi Apr 28 at 17:46
    
Yes very well! Thanks. –  Tarass Apr 28 at 18:18

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.