我使用 tikz 绘制了一幅图像,下面是图像的一部分。但是变量名是居中对齐,如何使其右对齐?
以下是相关代码
\foreach \i [count=\j from 1] in {5,4,3,2,1} {
\pic () at (-0.5,\i) {myarrow};
\node[xshift=-2.5cm] at (-1,\i) {VARIABLE NAME};
}
答案1
这是您想要的吗?使用text width=the longest length and align=left,center, right
您的选择。
代码
\documentclass[border=10pt]{standalone}%[12pt,twoside,a4paper]{book}
\usepackage{graphicx,wrapfig,tikz}
\usetikzlibrary{positioning,shapes}
\tikzset{myarrow/.pic = {
\begin{scope}[rotate=-90,scale=0.5]
\draw[fill=black] (-0.5,0) -- (0,0.5)--(0.5,0)--(0.5,1)--
(0,1.5)--(-0.5,1)--(-0.5,0) ;
\end{scope}},
}
\begin{document}
\begin{tikzpicture}
\draw (0,0) rectangle (0,6);
% draw myarrows on the left side
\foreach \i/\k in {5/{FUEL\_LEVEL\_TOT},4/{PBRAKE\_APPLIED\_HIGH},
3/{FUEL\_VOLUME},2/{FUEL\_LEVEL},1/{FUEL\_CONSUMPTION\_RATE}} {
\pic () at (-0.5,\i) {myarrow};
\node[xshift=-6cm,text width=8cm,align=right] at (-1,\i) {RTDB\_{\k}\_E};
}
\end{tikzpicture}
\end{document}