# Question

I want to shift some TikZ coordinates in units of the line width (stroke width). When I use some externally defined length as the line width, it is not affected by scaling, which is what I want. However, coordinates, offset, or similar specified in that length are.

How can I specify some TikZ coordinate, offset, or similar in terms of the actually used line width? I prefer solutions that also work with non-integer multiples of the line width, but I am also interested in those that don’t.

# Example

\documentclass{standalone}
\usepackage{tikz}

\newlength{\mylinewidth}
\setlength{\mylinewidth}{10pt}

\newcommand{\twolines}{
\draw[line width=\mylinewidth, yshift= \mylinewidth] (-1,0) -- (1,0);
\draw[line width=\mylinewidth, yshift=-\mylinewidth] (-1,0) -- (1,0);
}

\begin{document}
\begin{tikzpicture}
\twolines
\node[font=\tiny] {one line width};
\end{tikzpicture}

\begin{tikzpicture}[scale=0.7]
\twolines
\node[font=\tiny] {not one line width};
\end{tikzpicture}
\end{document}


This yields:

I want the second pair of lines to have a distance of one line width like the first pair.

# What I found

This question is similar. However, I cannot use shift only since in my case it is shifts that are affected. I could theoretically use a macro for the scale, but that would probably be very tedious in my actual application since I use many complex macros as in the above.

Coordinates are scaled but line widths are not.

pics are normally not scaled unless the transform shape option is provided.

\documentclass[border=1cm]{standalone}
\usepackage{tikz}

\newlength{\mylinewidth}
\setlength{\mylinewidth}{10pt}

\tikzset{
twolines/.pic={
\draw[line width=\mylinewidth, yshift= \mylinewidth] (-1,0) -- (1,0);
\draw[line width=\mylinewidth, yshift=-\mylinewidth] (-1,0) -- (1,0);
}
}

\begin{document}
\begin{tikzpicture}
\pic{twolines};
\node[font=\tiny] {one line width};
\end{tikzpicture}

\begin{tikzpicture}[scale=0.7]
\pic{twolines};
\node[font=\tiny] {scaled but one line width};
\end{tikzpicture}

\begin{tikzpicture}[scale=0.7]
\pic[transform shape]{twolines};
\node[font=\tiny] {scaled but not one line width};
\end{tikzpicture}
\end{document}