在下面的代码中,我想更改底线的长度 - 红色箭头,见附图。我知道如何在通常的代码行中执行此操作,但是这段代码(复制并粘贴以创建垂直线,我不确定,我尝试过 length=3, length=3cm ,在“<->”之后,但它会显示错误。非常感谢!
\documentclass[journal]{IEEEtran}
\usepackage{pgf,pgfarrows,pgfnodes,pgfautomata,pgfheaps}
\usepackage{graphicx}
\usepackage[T1]{fontenc}
\usepackage{amsfonts}
%\usepackage[pdftex]{graphicx}
% Comment the following line to NOT allow the usage of umlauts
\usepackage{pgfgantt}
\usetikzlibrary{angles,calc,math}
\usepackage{tkz-euclide}
\usepackage{pdflscape}
% Start the docu
\usepackage{xcolor}
\usetikzlibrary{positioning}
\usepackage{amsmath}
\usepackage{tikz}
\bibliographystyle{IEEEtran}
%\pagestyle{fancyplain}
\begin{document}
\begin{figure}
\centerline
{\begin{tikzpicture}
\draw[dashed] (0,0)--(7,3);
\draw[dashed] (7,3)--(7,0);
\draw [dashed] (7,0)--(0,0);
\node[right] at (0.6,0.1) {$\theta$};
\draw[<->, ultra thin,gray](7.1,2.7)--(0.1,-0.28);
\node [below] at (3.6, 1.3) {$L_p$};
\draw [->, ultra thick](7,3)--(6.6,2.8) ;
%^ x axis
%addgravitylabel
\draw[->, ultra thick] (3,4)--(3,3.5);
\node[left] at (3,4.0){$\bf{g}$};
\node [below] at (6.8,2.9) {X};
% S(X)
\draw [thick ] (4,1.75) to [out=90,in=180] (5,2.15);
to [out=0,in=180] (5.5,2.0) to [out=0,in=-135] (6.0,2.6);
\draw [thick] (6,2.6) to [out=90,in=180] (7,3.05);
\draw[thick](5,2.15)--(6,2.6);
\draw[thick](4,1.75)--(0,0);
%F(X,T)
\draw [thick, ] (0,1) to [out=90,in=180] (1,1.45)
to [out=0,in=180] (1.5,1.37) to [out=0,in=-135] (2.0,1.9) ;
\draw [,thick, ] (2,1.9) to [out=90,in=180] (3,2.35)
to [out=0,in=180] (3.5,2.25) to [out=0,in=-135] (4.0,2.75);
\draw [,thick, ] (4,2.75) to [out=90,in=180] (5,3.2)
to [out=0,in=180] (5.5,3.1) to [out=0,in=-135] (6.0,3.6);
\draw [,thick,] (6,3.6) to [out=90,in=180] (7,4.05);
\draw [thin, ] (2.5,0) to [out=90,in=0] (2,0.85);
%length and depth
%free-surfacelabel
%inclineplanelabel
\draw[ <-, thin] (6,2.6)--(5.5,4.3);
\draw[<-, thin] (1,1.45)--(-0.7,2.8);
\node at (5.5,4.3) {$S(X)$};
%\node[above]
\node at (-0.8,3) {$F(X,T)$};
% Z AXIS To change
\draw [->,ultra thick] (7,3)--(6.7,3.5);
\node[right] at (7,3.3) {Z};
% PERPENDICULAR QUESTION HERE !!
%\draw [<->,thin] (3.6,1.5)--(3.55,2.28) ;
\node[right] at (4.5,2.7) {H(X,T)};
%\node[color=blue] at (5.4,2.3){dfd};
%\tkzDefLine[orthogonal=through C](C,O);
%\tkzDrawLine[,add = .6 and 0.02,color=black](O,tkzPointResult);
\coordinate (O) at (5.7,2.5) ;
\coordinate (E) at (5.4,2.35);
\draw[thick] (O)--(E) node[pos=3.0,color=white](x){a} ;
\draw[red,<->,thin,transform canvas={rotate around={90:(x)}}] (O) -- (E) ;
\end{tikzpicture}}
\end{figure}
\end{document}
答案1
我试着猜测你想要什么,然后重写你的所有代码。具体来说,我使用calc
- 你可以在手册中找到解释。使用明确的坐标也是完全可以接受的。
\documentclass[tikz, border=1cm]{standalone}
\usepackage{tikz-dimline}
\usetikzlibrary{angles, quotes, calc}
\begin{document}
\begin{tikzpicture}[>=latex]
\coordinate (A) at (0,0);
\coordinate (B) at (7,3);
\coordinate (C) at (7,0);
\draw[dashed] (A)--(B)--(C)--cycle;
\draw pic["$\theta$", draw, angle radius=2cm, angle eccentricity=0.8] {angle=C--A--B};
\dimline{ ($ (B)!1cm!90:(A) $) } { ($ (A)!1cm!-90:(B) $) } {$L_P$};
\draw[->, ultra thick] (B) -- node[right]{$\vec Z$} ($ (B)!0.5cm!-90:(A) $);
\draw[->, ultra thick] (B) -- node[below]{$\vec X$} ($ (B)!0.5cm!(A) $);
\draw[->, ultra thick] (3,4) -- node[left] {$\vec g$} (3,3.5);
\draw [thick ] ($(A)+(0,0.1) $) -- (4,1.8) to [out=90,in=180] (5,2.2) -- (5.9,2.6) to [out=90,in=180] (6.8,3);
\draw [thick, ] (0,1) to [out=90,in=180] (1,1.45) to [out=0,in=180] (1.5,1.37) to [out=0,in=-135] (2,1.9) to [out=90,in=180] (3,2.35) to [out=0,in=180] (3.5,2.25) to [out=0,in=-135] (4,2.75) to [out=90,in=180] (5,3.2) to [out=0,in=180] (5.5,3.1) to [out=0,in=-135] (6,3.6) to [out=90,in=180] (7,4.05);
\draw[ <-] (6.2,2.7)--(5.5,4.3) node[above] {$S(X)$};
\draw[<-] (0.5,1.5)--(-0,2.8) node[above] {$F(X,T)$};
\draw[red,<->] ($ ($ (B)!2.5cm!(A) $)!0.3cm!90:(B) $) -- ($ ($ (B)!2.5cm!(A) $)!1.1cm!90:(B) $);
\node[right] at (4.4,2.7) {H(X,T)};
\end{tikzpicture}
\end{document}
编辑:
从calc
⟨a⟩!⟨factor⟩!⟨angle⟩:⟨b⟩ 的一般含义是:“首先,考虑从 ⟨a⟩ 到 ⟨b⟩ 的直线。然后以点 ⟨a⟩ 为中心,将这条直线旋转 ⟨angle⟩ 个角度。那么这条直线的两个端点就是 ⟨a⟩ 和某个点 ⟨c⟩。利用这个点 ⟨c⟩ 进行后续计算,也就是部分计算。”
- 只需查看手册中第 150 页的示例就容易多了。