将线标旋转至水平

将线标旋转至水平

我想旋转标签以使我的线始终保持水平,而不必计算旋转角度,因为它们很多。

梅威瑟:

\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

必须告诉 TiZ 不要倾斜。

\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}

相关内容