Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to draw a rather simple tikz picture that consists of some very acurately defined levels. My code is

\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}

As you can see I have set a length called offset. The problem is that at the present point the picture is rather big. What I want is to scale it only on y axis. If I change \begin{tikzpicture}[y=1cm] to \begin{tikzpicture}[y=.6cm] I get the ideal y dimension but the levels on the output channel are not set correctly.

Is there a way to define a length in tikz that will adapt tikz's lengths? What I mean is that by default tikz's length is 1cm. When using \draw (0,0) -- (0,1); one does not specify that he's talking about cm. If the global length is changed(i.e. `[y=0.6]) the previous line will have 0.6 cm length. Is something like that possible?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Remarks

Use a macro to store the pure value, such that tikz can scale it using it's own units.

Implementation

\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}

Output

enter image description here

share|improve this answer
    
Thank you very much for your answer! That was an interesting approach! Very clever! Thank's!!! –  Thanos Dec 29 '13 at 13:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.