pgf icon indicating copy to clipboard operation
pgf copied to clipboard

diamond shape: keep aspect when checking against minimum ht/wd

Open muzimuzhi opened this issue 4 years ago • 3 comments

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}

image

Checklist

Please check the boxes below and signoff your commits to explicitly state your agreement to the Developer Certificate of Origin:

  • [x] Code changes are licensed under GPLv2 + LPPLv1.3c
  • [x] Documentation changes are licensed under FDLv1.2

muzimuzhi avatar Aug 19 '21 21:08 muzimuzhi

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:

  1. Take it as a documented feature and maybe document the relation between /pgf/shape aspect and /pgf/aspect.
  2. Change the precedence for both diamond and cylinder, which is certainly a breaking change.

muzimuzhi avatar Aug 19 '21 22:08 muzimuzhi

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.

hmenke avatar Aug 20 '21 06:08 hmenke

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}

image

muzimuzhi avatar Aug 20 '21 18:08 muzimuzhi