0

I want to rotate a label for my dimline to always be horizontal without having to calculate the rotation angle since they are numerous.

MWE:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{tikz}
\usepackage{tikz-dimline}
\begin{document}
\begin{tikzpicture}
\node[inner sep=0pt] (im) at (0,0) 
{\includegraphics[scale=1]{example-image}};
\dimline[color = white, 
     line style = {line width = 0.7},
     label style = {anchor = south, fill = none }] 
         {(-1.2,-1.3)}
         {(2,1.6)}
         {$w$};
\end{tikzpicture}
\end{document}

MWE

1

One has to tell TikZ not to slope.

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{tikz}
\usepackage{tikz-dimline}
\tikzset{no slope/.code={\pgfslopedattimefalse}}
\begin{document}
\begin{tikzpicture}
\node[inner sep=0pt] (im) at (0,0) 
{\includegraphics[scale=1]{example-image}};
\dimline[color = white, 
     line style = {line width = 0.7},
     label style = {above=2mm, fill = none,no slope}] 
         {(-1.2,-1.3)}
         {(2,1.6)}
         {$w$};
\end{tikzpicture}
\end{document}

enter image description here

  • Thanks for this approach, really easy to implement and change the anchor points change the position of the label! – Mats Nilsson May 9 '18 at 18:46
  • check! sorry for the delay. – Mats Nilsson May 9 '18 at 20:29
4

like this:

enter image description here

but this is drawn by pure tikz:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,quotes}
%\usepackage{tikz-dimline}

\begin{document}
\begin{tikzpicture}
\node[inner sep=0pt] (im) at (0,0)
{\includegraphics[scale=1]{example-image}};
\draw[color = white,{Bar[]Stealth[]}-{Stealth[]Bar[]}, line width = 0.7]
    (-1.2,-1.3) to ["$w$"] (2,1.6);
\end{tikzpicture}
\end{document}

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.