pgf
pgf copied to clipboard
diamond shape: keep aspect when checking against minimum ht/wd
Motivation for this change
Currently, when a diamond shape is enlarged when checking against minimum height/width, the shape aspect is not kept. This PR fixes the problem.
Example
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
% shape aspect is initially 1
\begin{tikzpicture}[nodes={diamond, draw}]
\node[minimum width=50pt] {x};
\node[minimum height=50pt] at (2,0) {x};
\end{tikzpicture}
\end{document}

Checklist
Please check the boxes below and signoff your commits to explicitly state your agreement to the Developer Certificate of Origin:
Hmm, pgfmanual reads "the aspect (set by /pgf/aspect/) is a recommendation" for shapes diamond and cylinder.
https://github.com/pgf-tikz/pgf/blob/85d2c38b78407e5b1ba42140dfd11fcdf8df1edf/doc/generic/pgf/text-en/pgfmanual-en-library-shapes.tex#L112-L115
Though the relation between /pgf/shape aspect and /pgf/aspect is not explicitly documented, the above doc suggests what this PR tries to fix is a documented "feature". I still think that minimum height/width has higher precedence than shape aspect is strange.
Therefore this PR may end in one of two ways:
- Take it as a documented feature and maybe document the relation between
/pgf/shape aspectand/pgf/aspect. - Change the precedence for both
diamondandcylinder, which is certainly a breaking change.
Unfortunately, we can't do that. What we can do, however, is change the default value for shape aspect to unset and use it if the user explicitly sets a value.
Please review if the current implementation is "what we can do". If so, I will do the same for shapes cylinder and cloud.
Also can the aspect staff common in libs shapes.geometric and shapes.symbols be moved to a separate file, probably named sth ends with shapes.common.code.tex?
Feels like we can only add features if there's a crack in the manual wall. :)
Examples, new
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
\tikzset{nodes={diamond, draw}, baseline=0pt}
\def\demo#1{%
\def\tmp{#1}%
\ifx\tmp\empty default\else \texttt{#1}\fi:
\begin{tikzpicture}[style/.expanded={#1}]
\node[minimum width=50pt] {x};
\node[minimum height=50pt] at (2,0) {x};
\end{tikzpicture}
}
\demo{}\par
\demo{shape aspect=none}
\foreach \v in {1, 2, .5} {
\foreach \k in {shape aspect, aspect} {
\demo{\k=\v}\qquad
}\par
}
\end{document}
