私は非常に正確に定義されたいくつかのレベルで構成されるかなり単純なtikz画像を描こうとしています。私のコードは次のとおりです。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{plotmarks}
\newlength{\offset}
\setlength{\offset}{4.72983cm}
\begin{document}
\begin{tikzpicture}[y=1cm]
%axis
\draw (-3,0) -- coordinate (y axis mid) (-3,20);
%ticks
\foreach \y in {0,2,...,20}
\draw (-3,\y) -- (-3.25,\y)
node[anchor=east] {\y};
%labels
\node[rotate=90, above=0.8cm] at (y axis mid) {\textbf{Energy[MeV]}};
%input channel
\draw (-2,12.8435) -- (0,12.8435);
\node[above=0.2cm] at (-1,12.8435) {$p+{}^{19}F$};
%compound nucleus
\draw[very thick] (2,20) -- (2,0) -- (5,0) -- (5,20);
\node[below=0.1cm] at (3.5,0) {${}^{20}Ne$};
%output channel
\draw (7,\offset) -- (9,4.72983);%ground state
\draw (7,5.98765+\offset) -- (9,5.98765+4.72983);%1st state
\end{tikzpicture}
\end{document}
ご覧のとおり、 という長さを設定しましたoffset
。問題は、現時点では画像がかなり大きいことです。私がしたいのは、 のみで拡大縮小することです。にy axis
変更すると、理想的な寸法が得られますが、 のレベルは正しく設定されません。\begin{tikzpicture}[y=1cm]
\begin{tikzpicture}[y=.6cm]
y
output channel
tikz
tikz の長さに適合する長さを定義する方法はありますか? つまり、デフォルトでは tikz の長さは です1cm
。 を使用する場合、\draw (0,0) -- (0,1);
cm について話しているかどうかは指定しません。グローバル長さが変更された場合 (つまり、`[y=0.6])、前の行の長さは 0.6 cm になります。そのようなことは可能ですか?
答え1
備考
マクロを使用して純粋な値を保存し、tikz
独自の単位を使用してスケーリングできるようにします。
実装
\documentclass[tikz]{standalone}
\usetikzlibrary{plotmarks}
\newcommand{\offset}{4.72983}
\begin{document}
\begin{tikzpicture}[y=0.2cm]
%axis
\draw (-3,0) -- coordinate (y axis mid) (-3,20);
%ticks
\foreach \y in {0,2,...,20}
\draw (-3,\y) -- (-3.25,\y)
node[anchor=east] {\y};
%labels
\node[rotate=90, above=0.8cm] at (y axis mid) {\textbf{Energy[MeV]}};
%input channel
\draw (-2,12.8435) -- (0,12.8435);
\node[above=0.2cm] at (-1,12.8435) {$p+{}^{19}F$};
%compound nucleus
\draw[very thick] (2,20) -- (2,0) -- (5,0) -- (5,20);
\node[below=0.1cm] at (3.5,0) {${}^{20}Ne$};
%output channel
\draw (7,\offset) -- (9,4.72983);%ground state
\draw (7,5.98765+\offset) -- (9,5.98765+4.72983);%1st state
\end{tikzpicture}
\end{document}