我想旋转标签以使我的线始终保持水平,而不必计算旋转角度,因为它们很多。
梅威瑟:
\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}
答案1
必须告诉 Ti钾Z 不要倾斜。
\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}
答案2
像这样:
但这是纯粹的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}