비고

비고

나는 매우 정확하게 정의된 레벨로 구성된 다소 간단한 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올바르게 설정되지 않습니다.

tikztikz의 길이에 맞게 길이를 정의하는 방법이 있습니까 ? 내 말은 기본적으로 tikz의 길이는 1cm. 하나를 사용할 때 \draw (0,0) -- (0,1);cm에 대해 이야기하고 있음을 지정하지 않습니다. 전역 길이가 변경되면(예: `[y=0.6]) 이전 줄의 길이는 0.6cm가 됩니다. 그런 일이 가능합니까?

답변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}

산출

여기에 이미지 설명을 입력하세요

관련 정보