2

The documentation of TikZ seems to indicate that shape aspect is available for all node shapes. However, the command is only available if shapes.geometric is loaded and for some shapes (e.g. diamond). I tried to apply it to a rectangle, but without success:

\documentclass[tikz]{standalone}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}
  \newcommand\ww{4cm}
  \node[draw, minimum width=\ww,shape aspect=5] {};
  %  works
  \node[draw, diamond, minimum width=\ww,shape aspect=5, yshift=-1cm] {};
\end{tikzpicture}
\end{document}

Did I miss something? How can I construct rectangles with minimum width and a ratio? Do I have to use the painful \pgfmathresult macros to calculate it manually (I dislike them).

4

There is none but you can cook up yourself. Here is my two-minute mock-up without much thinking because I'm watching something else with my other eye

\documentclass[tikz]{standalone}
\tikzset{
  adjust height/.style={minimum height=#1*\pgfkeysvalueof{/pgf/minimum width}},
  adjust width/.style={minimum width=#1*\pgfkeysvalueof{/pgf/minimum height}}
}
\begin{document}
\begin{tikzpicture}
\node[fill=blue!40,minimum width=2cm,adjust height=3] (a) at (0,0) {Lawrence Tierney};
\node[fill=orange!50!black,minimum height=2cm,adjust width=3] (a) at (5,0) {Tim Roth};
\end{tikzpicture}
\end{document}

enter image description here

  • This method is nice, I've come across the \pgfkeysvalueof macro. I'll accept this answer soon, but I want to be the one pushing you above 100k rep (perhaps happening today). – Sebastian Aug 25 '15 at 8:35

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.