Skip to content

sloped should consider the current transformation #1058

@thinbold

Description

@thinbold

Brief outline of the proposed feature

Inspired by this SX question and this older one,
I would like to suggest that we should consider the current transformation
when computing the slope of the sloped nodes.

Usage example

The following code

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[xscale=2, yscale=3, xshift=40, yshift=50]
	\draw (0, 0) -- node[sloped, above] {sloped correctly?} (1, 1);
\end{tikzpicture}
\end{document}

produces a line and a node that do not align.
This is because in the definition of \pgftransformlineattime,
the slope is calculated using the start and end coordinates
without applying the current transformation.
(For instance, in the above example, the diff vector will be (1cm, 1cm), not (2cm, 3cm).)
If we take that into account, a proper slope can be computed.

See my answer for one possible fix.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions