Tikz-timing 中的 \flusright

Tikz-timing 中的 \flusright

平均能量损失

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usepackage{tikz-timing}
\usetikztiminglibrary{nicetabs}

\newcommand\gtikzset[1]{%
\begingroup%
\globaldefs=1\relax%
\pgfqkeys{/tikz}{#1}%
\endgroup}

\begin{document}
\begin{tikztimingtable}[
scale=2,
timing/rowdist=3ex,
]
\textnormal{}  &   @{\gtikzset{timing/rowdist=1}}\\
\textnormal{RS--232 Signal}  & @{\gtikzset{timing/rowdist=1}}\\
\textnormal{}  & @{\gtikzset{timing/rowdist=1}}\\
\textnormal{}  &  [y=4\yunit][line width=1pt] U L 2H 2L 5{2H} 2L 2L 2H 2{2L} L U \\
\extracode
\begin{pgfonlayer}{background}
%Left
\node[anchor=east] at (row1.north west){\scriptsize +15V};
\node[anchor=east] at (row3.west){\scriptsize --3V};
\node[anchor=east] at (row3.north west){\scriptsize 0V};
\node[anchor=east] at (row2.west){\scriptsize +3V};
\node[anchor=east] at (row4.south west){\scriptsize --15V};
%Right
\node[anchor=west] at (28,1){\scriptsize +15V};
\node[anchor=west] at (28,-0.5){\scriptsize +3V};
\node[anchor=west] at (28,-1){\scriptsize \phantom{+}0V};
\node[anchor=west] at (28,-1.5){\scriptsize --3V};
\node[anchor=west] at (28,-3){\scriptsize --15V};
%Horivontal
\shade[right color=red!60,left color=red!60](28,-0.5) rectangle(0,-1.5);
\shade[right color=green!60,left color=green!60](28,1) rectangle(0,-0.5);
\shade[right color=green!60,left color=green!60](28,-1.5) rectangle(0,-3);
%Vertical
\shade[right color=yellow!60,left color=yellow!60](2,-3) rectangle(1,1);
\shade[right color=yellow!60,left color=yellow!60](26,-3) rectangle(27,1);
\end{pgfonlayer}
\tablegrid
\end{tikztimingtable}
\end{document}

并输出, 在此处输入图片描述

我的问题是(像-3V)所有正确的电压定义都不正确。我该怎么办?

答案1

尝试选择anchor与左侧组相同的内容,然后添加 x 偏移来补偿这一点。请注意,偏移的长度单位应相对于字体大小(em、ex 等)进行选择,而不是固定单位(pt、in、mm、cm 等)。

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usepackage{tikz-timing}
\usetikztiminglibrary{nicetabs}

\newcommand\gtikzset[1]{%
\begingroup%
\globaldefs=1\relax%
\pgfqkeys{/tikz}{#1}%
\endgroup}

\begin{document}
\begin{tikztimingtable}[
scale=2,
timing/rowdist=3ex,
]
\textnormal{}  &   @{\gtikzset{timing/rowdist=1}}\\
\textnormal{RS--232 Signal}  & @{\gtikzset{timing/rowdist=1}}\\
\textnormal{}  & @{\gtikzset{timing/rowdist=1}}\\
\textnormal{}  &  [y=4\yunit][line width=1pt] U L 2H 2L 5{2H} 2L 2L 2H 2{2L} L U \\
\extracode
\begin{pgfonlayer}{background}
%Left
\node[anchor=east] at (row1.north west){\scriptsize +15V};
\node[anchor=east] at (row3.west){\scriptsize --3V};
\node[anchor=east] at (row3.north west){\scriptsize 0V};
\node[anchor=east] at (row2.west){\scriptsize +3V};
\node[anchor=east] at (row4.south west){\scriptsize --15V};
%Right
\node[anchor=east,xshift=6ex] at (28,1){\scriptsize +15V};
\node[anchor=east,xshift=6ex] at (28,-0.5){\scriptsize +3V};
\node[anchor=east,xshift=6ex] at (28,-1){\scriptsize \phantom{+}0V};
\node[anchor=east,xshift=6ex] at (28,-1.5){\scriptsize --3V};
\node[anchor=east,xshift=6ex] at (28,-3){\scriptsize --15V};
%Horivontal
\shade[right color=red!60,left color=red!60](28,-0.5) rectangle(0,-1.5);
\shade[right color=green!60,left color=green!60](28,1) rectangle(0,-0.5);
\shade[right color=green!60,left color=green!60](28,-1.5) rectangle(0,-3);
%Vertical
\shade[right color=yellow!60,left color=yellow!60](2,-3) rectangle(1,1);
\shade[right color=yellow!60,left color=yellow!60](26,-3) rectangle(27,1);
\end{pgfonlayer}
\tablegrid
\end{tikztimingtable}
\end{document}

在此处输入图片描述

另一个选择是保持anchor=west原样并指定text width足够宽以容纳所有标签并与右侧对齐,如下所示:

\node[anchor=west,text width=5ex,align=right] at (28,1){\scriptsize +15V};
\node[anchor=west,text width=5ex,align=right] at (28,-0.5){\scriptsize +3V};
\node[anchor=west,text width=5ex,align=right] at (28,-1){\scriptsize \phantom{+}0V};
\node[anchor=west,text width=5ex,align=right] at (28,-1.5){\scriptsize --3V};
\node[anchor=west,text width=5ex,align=right] at (28,-3){\scriptsize --15V};

相关内容