我试图编辑一个图表并添加一条尺寸线,如您在附图中看到的那样,但我无法到达适当的箭头来绘制相同的箭头,如果可以在 Latex 中做到这一点,我不知道该怎么做,有人能帮我吗?我正在阅读这些链接:这里和这里但我仍然不明白如何画一条直线......
我已经尝试过代码,到目前为止,我无法画出有两个头的箭头,它只出现在中间一端的一个头,就像你在旁边看到的字母 f 一样,我仍然不知道如何在线旁边写字母:
\documentclass[11pt,a4paper,twoside,openright]{report}
\usepackage{tikz}
\usetikzlibrary{calc,intersections,through,backgrounds}
\begin{document}
\begin{tikzpicture}[--, thick]
\draw (-10,0) -- (-9,1);
\draw (-9,1) -- (-7.5,1);
\draw (-7.5,1) -- (-6.5,0);
\draw (-6.5,0) -- (-5.5,-1);
\draw (-5.5,-1)-- (-4,-1);
\draw (-4,-1)-- (-3,0);
%dimensions
\draw [|<->|] (-8.25,0) -- (-8.25,1);
\draw [|<->|] (-10,-0.5) -- (-6.5,-0.5);
\begin{scope}[dash pattern=on 2pt off 3pt on 4pt off 4pt];
\draw[dashed] (-6.5pt,0pt) -- (-6.5pt,-1pt);
\end{scope}
\begin{scope}[ultra thick]
\draw [->] (-10.5,0) -- (-1.5,0);
\draw [->] (-10,-1.5) -- (-10,1.5);
\end{scope}
\end{tikzpicture}
\end{document}
答案1
这演示了如何向线条添加标签以及如何将虚线放置在正确的位置。请注意,(6.5pt,0.5pt)
通常与不同(6.5,0.5)
!我还稍微简化了您的路径规范并删除了不起作用的选项tikzpicture
。
midway
将标签放在中间,这是 和 所需要f
的c
。pos=.95
将标签放置在距离终点 95% 的位置,这是轴上标签所需要的。left
并below
指定标签相对于线的相对位置。
代码
\documentclass[tikz,border=10pt]{standalone}
\begin{document}
\begin{tikzpicture}[thick]
\draw (-10,0) -- (-9,1) -- (-7.5,1) -- (-6.5,0) -- (-5.5,-1) -- (-4,-1) -- (-3,0);
%dimensions
\draw [<->] (-8.25,0) -- (-8.25,1) node [midway, right] {$f$};
\draw [<->] (-10,-0.5) -- (-6.5,-0.5) node [midway, below] {$c$};
\draw [dashed] (-6.5,0) -- (-6.5,-.75);
\begin{scope}[ultra thick]
\draw [->] (-10.5,0) -- (-1.5,0) node [pos=.95, below] {$x$};
\draw [->] (-10,-1.5) -- (-10,1.5) node [pos=.95, left] {$y$};
\end{scope}
\end{tikzpicture}
\end{document}
答案2
JPEG 是一种非常糟糕的绘图格式。因此,最好重新绘制图像。以下示例使用 TikZ。该函数严格使用参数进行绘制F,C,α(\fHeight
,,\cWidth
)\alphaAngle
。
\documentclass{article}
%\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{bending}
\pagestyle{empty}
\begin{document}
\setlength{\unitlength}{.5mm}
\begin{tikzpicture}[
x=\unitlength,
y=\unitlength,
>=Triangle,
]
\def\fHeight{17}
\def\cWidth{50}
\def\alphaAngle{45}
\def\alphaRadius{14}
% Image as background as help for redrawing
% \node[
% inner sep=0pt,
% above right,
% ] at (-16.25, -20.75)
% {\includegraphics[width=150\unitlength]{QpYZE.jpg}}
% ;
% Coordinate axes
\begin{scope}[
thick,
->,
]
\draw (-9, 0) -- (125, 0) node[below left, xshift=-.5em] {$x$};
\draw (0, -20) -- (0, 30) node[below left, yshift=-.25em] {$z$};
\end{scope}
% Function
\pgfmathsetmacro{\xf}{\fHeight * cot(\alphaAngle)}
\draw[
semithick,
]
(0, 0)
-- (\xf, \fHeight) coordinate (A)
-- (\cWidth - \xf, \fHeight) coordinate (B)
-- (\cWidth + \xf, -\fHeight)
-- (2*\cWidth - \xf, -\fHeight)
-- (2*\cWidth, 0)
;
% Annotations
\begin{scope}[
thin,
<->,
shorten <=.4pt,
]
\draw[shorten >=.3pt]
(\cWidth/2, 0) -- node[right] {$f$} ++(0, \fHeight)
;
\draw[shorten >=.2pt]
(0, -6) -- node[below] (c) {$c$} ++(\cWidth, 0)
;
\draw[shorten <=.2pt, shorten >=.2pt]
(\xf, \fHeight + 4) -- node[above] (cp) {$c_p$}
(\cWidth - \xf, \fHeight + 4)
;
\draw[shorten >=.3pt, radius=\alphaRadius]
(\alphaRadius, 0) arc[start angle=0, end angle=\alphaAngle]
;
\node at (\alphaAngle/2:.65*\alphaRadius) {$\alpha$};
\end{scope}
% Help lines
\draw[thin, densely dashed]
(\cWidth, 0) -- (\cWidth, 0 |- c.south)
(A) -- (A |- cp.north)
(B) -- (B |- cp.north)
;
\end{tikzpicture}
\end{document}