Debian Codegraph @

texmf-dist/doc/latex/tikz-palattice/tikz-palattice_documentation.tex

raw
1 %% tikz-palattice_documentation.tex
2 %% Copyright 2017 J. Schmidt
3 %% tikz-palattice LaTeX package
4 %
5 % This work may be distributed and/or modified under the
6 % conditions of the LaTeX Project Public License, either version 1.3
7 % of this license or (at your option) any later version.
8 % The latest version of this license is in
9 % http://www.latex-project.org/lppl.txt
10 % and version 1.3 or later is part of all distributions of LaTeX
11 % version 2005/12/01 or later.
12 %
13 % This work has the LPPL maintenance status `maintained'.
14 %
15 % The Current Maintainer of this work is J. Schmidt.
16 %
17 % This work consists of the files tikz-palattice.sty and tikz-palattice_documentation.tex
18 % and the 5 example files example1_linear.tex, example2_circular.tex,
19 % example3_coordinates.tex, example4_labels.tex and elsa.tex
20
21 \documentclass[a4paper]{scrartcl}
22 \usepackage[english]{babel}
23 \usepackage[utf8]{inputenc}
24 \usepackage[T1]{fontenc}
25 \usepackage{lmodern}
26 \usepackage{subcaption}
27 \usepackage{amsmath}
28 \usepackage{textcomp}
29 \usepackage{marvosym}
30 \usepackage{amssymb}
31 \usepackage[colorlinks]{hyperref}
32 \usepackage{siunitx}
33 \usepackage{listings}
34 \usepackage{xcolor}
35 \usepackage{tikz-palattice}
36
37 \newcommand{\option}[1]{{\color{blue}$\langle$\textit{#1}$\rangle$}}
38 \newcommand{\optiondef}[2]{{\color{green!50!black}$\langle$\textit{#1=#2}$\rangle$}}
39 \newcommand{\tikzlabel}{Ti\textit{k}Z}
40
41 \author{Jan Schmidt <[email protected]>}
42 \date{v2.3 (March 9, 2017)}
43 \title{tikz-palattice - draw particle accelerator lattices with \tikzlabel}
44
45 \hypersetup{
46 pdftitle={tikz-palattice - draw particle accelerator lattices with \tikzlabel},
47 pdfauthor={Jan Schmidt}
48 }
49
50 \begin{document}
51
52 \definecolor{keycolor}{RGB}{172, 42, 42}
53 \lstset{
54 basicstyle=\small\sffamily,
55 backgroundcolor=\color{gray!20},
56 %numbers=left,
57 numberstyle=\tiny,
58 breaklines=true,
59 %frame=l,
60 xleftmargin=\parindent,
61 columns=fullflexible,
62 showstringspaces=false,
63 keywordstyle=\bfseries\color{keycolor},
64 commentstyle=\color{black!50},
65 identifierstyle=,%\color{blue},
66 stringstyle=,
67 escapeinside={(*}{*)}
68 }
69
70 \maketitle
71
72 \begin{abstract}
73 The tikz-palattice package allows for drawing a map of a particle accelerator just by
74 giving a list of elements - similar to lattice files for simulation software. The
75 package includes 12 common element types like dipoles, quadrupoles, cavities or screens,
76 as well as automatic labels with element names, a legend, a rule and an environment to
77 fade out parts of the accelerator. The coordinate of any element can be saved and used
78 for custom tikz drawings or annotations. Thereby, lattices can be connected to draw
79 injection/extraction or even a complete accelerator facility.
80 \end{abstract}
81
82
83 \begin{figure}[h]
84 \centering
85 \includegraphics[width=\textwidth]{elsa.pdf}
86 \caption{The Electron Stretcher Facility ELSA at Bonn University, drawn with
87 tikz-palattice}
88 \label{fig:elsa}
89 \end{figure}
90
91
92 \clearpage
93 \parindent=0pt
94 Copyright 2017 Jan Schmidt
95
96 \medskip
97 Permission is granted to distribute and/or modify both the documentation and the code
98 under the conditions of the LaTeX Project Public License, either version 1.3 of this
99 license or (at your option) any later version. The latest version of this license is in
100 http://www.latex-project.org/lppl.txt
101
102 \tableofcontents
103
104 \section{Installation}
105 \label{sec-1}
106 \subsection{Copy tikz-palattice.sty}
107 \label{sec-1-1}
108 You just need to copy the lattice.sty file to a place where your \LaTeX{} installation can recognize it.
109 This can be
110 \begin{itemize}
111 \item the same folder as your .tex document or
112 \item in the \LaTeX{} system or user tree.
113 \end{itemize}
114 E.g. to add it to the system tree for texlive under ubuntu:
115 \begin{lstlisting}
116 sudo mkdir -p /usr/local/share/texmf/tex/latex/lattice/
117 sudo cp lattice.sty /usr/local/share/texmf/tex/latex/lattice/
118 sudo mktexlsr
119 \end{lstlisting}
120 For this path there is also a Makefile prepared, so just enter
121 \begin{lstlisting}
122 sudo make install
123 \end{lstlisting}
124 Otherwise read the documentation of your \LaTeX{} distribution.
125
126 \subsection{Required packages}
127 \label{sec-1-2}
128 \begin{itemize}
129 \item tikz
130 \item siunitx
131 \item ifthen
132 \item xargs
133 \item etoolbox
134 \item iflang
135 \end{itemize}
136
137 \lstset{language=[LaTeX]TeX}
138
139 \section{Basic Usage}
140 \label{sec:remarks}
141
142 Basically, an accelerator lattice is drawn by writing element commands one after the
143 other. White spaces and newlines are ignored. Usually you will use one \lstinline+drift+
144 and one other element alternately:
145
146 \begin{minipage}[c]{0.5\textwidth}
147 \begin{lstlisting}
148 \begin{lattice}
149 \source{Gun}{0.4}
150 \drift{0.267}
151 \quadrupole{Q1}{0.4}
152 \drift{0.29}
153 \dipole{M1}{0.8}{30}
154 \drift{0.29}
155 \kicker{VC1}{0.1}
156 \drift{0.2}
157 \end{lattice}
158 \end{lstlisting}
159 \end{minipage}
160 %
161 \begin{minipage}[c]{0.5\textwidth}
162 \begin{center}
163 \begin{lattice}
164 \source{Gun}{0.4}
165 \drift{0.267}
166 \quadrupole{Q1}{0.4}
167 \drift{0.29}
168 \dipole{M1}{0.8}{30}
169 \drift{0.29}
170 \kicker{VC1}{0.1}
171 \drift{0.2}
172 \end{lattice}
173 \end{center}
174 \end{minipage}
175
176
177 Descriptions of the commands are given in section \ref{sec-5}. There are 5 examples coming
178 with this package. Some of the drawings are shown in this document. Please look at the
179 separate tex-files for the source code.
180
181 \paragraph{Some general remarks:}
182 \begin{itemize}
183 \item it is recommended to draw lattices using \lstinline+\documentclass{standalone}+
184 especially for larger beamlines.
185 \item lengths are set in meter, so you write \{1.32\} for \SI{1.32}{\m}.
186 \item beamline with angle \SI{0}{\degree} goes to the right, positive angles bend counter clockwise.
187 \item some commands use the \tikzlabel{} \textit{north/east/south/west} terms. \textit{east}
188 of an element is always where the beam leaves the element (downstream) and \textit{west} is where the
189 beam enters the element (upstream).
190 \item settings (colors, font, rotatelabel,\ldots{}) changed within a \verb+scope+ environment are set back to the previous values outside of \verb+scope+
191 \item picture scale: for lattice scale=1 an element of 1m length is plotted with \SI{2}{\cm} length
192 \end{itemize}
193
194 Below, the arguments of commands are given in angle brackets. The values after an equal
195 sign are default values of optional arguments. E.g. \optiondef{scale}{1} indicates that
196 the default value of "scale" is 1.
197
198
199
200 \section{The lattice Environment}
201 \label{sec-4}
202
203 To draw a lattice just add
204 \begin{lstlisting}
205 \usepackage{tikz-palattice}
206 \end{lstlisting}
207 to your preambel and use the lattice environment with
208 \begin{lstlisting}
209 \begin{lattice}[(*\optiondef{scale}{1}*)][(*\optiondef{tikz options}{}*)]
210 ...
211 \end{lattice}
212 \end{lstlisting}
213 The \lstinline+lattice+ environment contains a \lstinline+tikzpicture+ environment in
214 which the lattice is drawn using usual tikz commands. The \lstinline+lattice+ environment
215 has 2 optional arguments:
216 \begin{enumerate}
217 \item \optiondef{scale}{1} scales whole picture (default is 1).
218 \item \optiondef{tikz options}{} gives any options for the \lstinline+tikzpicture+ (e.g.
219 overlay, default is none).
220 \end{enumerate}
221
222
223 \section{Within lattice Environment}
224 \label{sec-5}
225
226 \subsection{Elements}
227 \label{sec-5-1}
228
229 Here is a list of all implemented element types. The element names are self-explanatory:
230 \begin{lstlisting}
231 \drift{(*\option{length/m}*)}[(*\optiondef{name}{}*)]
232 \dipole{(*\option{name}*)}{(*\option{arc length/m}*)}{(*\option{bending angle/deg}*)}[(*\optiondef{type}{s}*)][(*\optiondef{thickness/m}{0.6}*)]
233 \quadrupole{(*\option{name}*)}{(*\option{length/m}*)}[(*\optiondef{thickness/m}{0.5}*)]
234 \sextupole{(*\option{name}*)}{(*\option{length/m}*)}[(*\optiondef{thickness/m}{0.3}*)]
235 \corrector{(*\option{name}*)}{(*\option{length/m}*)}[(*\optiondef{thickness/m}{0.25}*)]
236 \kicker{(*\option{name}*)}{(*\option{length/m}*)}[(*\optiondef{thickness/m}{0.25}*)]
237 \cavity{(*\option{name}*)}{(*\option{length/m}*)}[(*\optiondef{thickness/m}{0.45}*)]
238 \solenoid{(*\option{name}*)}{(*\option{length/m}*)}[(*\optiondef{thickness/m}{0.2}*)]
239 \beamdump{(*\option{name}*)}{(*\option{length/m}*)}[(*\optiondef{thickness/m}{0.5}*)]
240 \source{(*\option{name}*)}{(*\option{length/m}*)}[(*\optiondef{thickness/m}{0.5}*)]
241 \screen{(*\option{name}*)}[(*\optiondef{length/m}{0.2}*)]
242 \valve{(*\option{name}*)}
243 \marker{(*\option{name}*)}[(*\optiondef{length/m}{0.35}*)] % a line perpendicular to the beamline, see Fig. (*\ref{fig:example1}*)
244 \end{lstlisting}
245
246
247 \subsubsection{Dipole Types}
248 The \lstinline+dipole+ option \optiondef{type}{s} allows to select different dipole
249 shapes. It is shown in example~2. Possible values are:
250
251 \def\dipang{30}
252 \def\dipl{1.5}
253 \def\dipthick{0.3}
254 \begin{minipage}[c]{0.33\textwidth}
255 \centering
256 \begin{lattice}
257 \setangle{-\dipang/2}
258 \drift{0.1}
259 \dipole{s: sector magnet}{\dipl}{\dipang}[s][\dipthick]
260 \drift{0.1}
261 \end{lattice}
262 \end{minipage}
263 \begin{minipage}[c]{0.33\textwidth}
264 \centering
265 \begin{lattice}
266 \setangle{-\dipang/2}
267 \drift{0.1}
268 \dipole{r: rectangle magnet}{\dipl}{\dipang}[r][\dipthick]
269 \drift{0.1}
270 \end{lattice}
271 \end{minipage}
272 \begin{minipage}[c]{0.33\textwidth}
273 \centering
274 \begin{lattice}
275 \setangle{-\dipang/2}
276 \drift{0.1}
277 \dipole{br: bend rectangle magnet}{\dipl}{\dipang}[br][\dipthick]
278 \drift{0.1}
279 \end{lattice}
280 \end{minipage}
281
282 If you use any other letters, also the default (s) is used.
283
284
285 \begin{figure}
286 \centering
287 \includegraphics[width=10cm]{example1_linear}
288 \caption{Example 1}
289 \label{fig:example1}
290 \end{figure}
291
292
293 \subsection{Orientation of the lattice}
294 \label{sec-5-2}
295
296 \begin{lstlisting}
297 \start{(*\option{coordinate/m}*)}
298 \end{lstlisting}
299 sets starting point of the lattice. Use it before the first element. \option{coordinate/m}
300 is of form (x,y) or any tikz label, e.g. (mylabel.east) You can use this with
301 \lstinline+\savecoordinate+ (section \ref{sec:coords}) to connect lattices, but it is
302 recommended to do this via \lstinline+\goto+ (see below). Both are shown in example 3.
303
304 \begin{lstlisting}
305 \rotate{(*\option{angle/deg}*)}
306 \end{lstlisting}
307 bends the beamline by the given angle.
308
309 \begin{lstlisting}
310 \setangle{(*\option{angle/deg}*)}
311 \end{lstlisting}
312 sets the beamline angle to the given angle. The next element is drawn with beam axis in
313 this direction.
314
315 \begin{lstlisting}
316 \goto{(*\option{coordinate name}*)}
317 \end{lstlisting}
318 sets current position and angle to values saved
319 with \lstinline+\savecoordinate+ (section \ref{sec:coords}).
320 Use this to connect lattices and draw injection, extraction or even a complete accelerator
321 facility. This is shown in example 3.
322
323 \begin{figure}[h]
324 \centering
325 % this is the ring from example 2, but plotted smaller (30%).
326 % the element sizes (in meter) are the same - as the rule indicates.
327 \begin{lattice}[0.27]
328 \setlabelfont{\tiny}
329 \begin{labeldistance}{0.3}
330 \drift{1}
331 \dipole{M1}{2}{45}
332 \drift{1}
333 \turnlabels
334 \dipole{M2}{2}{45}
335 \turnlabels
336 \drift{1}
337 \dipole{M3}{2}{45}
338 \drift{1}
339 \savecoordinate{myCoord1}[center]
340 \dipole{M4}{2}{45}
341 \drift{1}
342 \dipole{M5}{2}{45}
343 \drift{1}
344 \dipole{M6}{2}{45}
345 \drift{1}
346 \savecoordinate{myCoord2}[center]
347 \dipole{M7}{2}{45}
348 \drift{1}
349 \dipole{M8}{2}{45}
350 \drawrule{(-2.5,-1)}[2]
351 \end{labeldistance}
352 % custom drawing using saved coordinates (to center of drifts)
353 \draw[->, thick] (myCoord2) -- (myCoord1) node[midway,fill=white,rotate=20] {signal};
354 \end{lattice}
355 \caption{From example 3}
356 \label{fig:fromexample3}
357 \end{figure}
358
359
360 \newpage
361 \subsection{Rule and Legend}
362 \label{sec:rule-legend}
363
364 \begin{lstlisting}
365 \drawrule{(*\option{position/m}*)}[(*\optiondef{tick distance/m}{1}*)][(*\optiondef{scale}{1}*)][(*\optiondef{height/m}{0.1}*)]
366 \end{lstlisting}
367 draws a rule to visualize the size of the lattice. Coordinate is of form (x,y) or any tikz
368 label, e.g. (mylabel.east)
369
370 \begin{lstlisting}
371 \legend{(*\option{position/m}*)}[(*\optiondef{scale}{1}*)]
372 \end{lstlisting}
373 draws a legend with all element types that occur in the lattice before this command.
374 The given \option{position/m} is north west (upper left corner) of the legend box.
375 The scale option scales the whole box including the text, which has the usual label
376 textsize if scale=1.
377
378 \begin{lstlisting}
379 \completelegend{(*\option{position/m}*)}[(*\optiondef{scale}{1}*)]
380 \end{lstlisting}
381 is similar to \lstinline+\legend+, but shows all element types.
382
383 The legend can be customized with the following two commands.
384 Here is an example for legend customizations:
385
386 \begin{minipage}[c]{0.5\textwidth}
387 \begin{lstlisting}
388 \begin{lattice}
389 \drift{0.2}
390 \quadrupole{Q1}{0.4}
391 \drift{0.1}
392 \kicker{C1}{0.1}
393 \drift{0.5}
394 \screen{S1}
395 \drift{0.2}
396 \setlegendtext{quadrupole}{I am focusing}
397 \addlegendentry{What's that?}{cyan, fill=violet}
398 \legend{(0.2,-1)}
399 \end{lattice}
400 \end{lstlisting}
401 \end{minipage}
402 %
403 \begin{minipage}[c]{0.5\textwidth}
404 \begin{center}
405 \begin{lattice}
406 \drift{0.2}
407 \quadrupole{Q1}{0.4}
408 \drift{0.1}
409 \kicker{C1}{0.1}
410 \drift{0.5}
411 \screen{S1}
412 \drift{0.2}
413 \setlegendtext{quadrupole}{I am focusing}
414 \addlegendentry{What's that?}{cyan, fill=violet}
415 \legend{(0.2,-1)}
416 \end{lattice}
417 \end{center}
418 \end{minipage}
419
420 \begin{lstlisting}
421 \setlegendtext{(*\option{type}*)}{(*\option{text}*)}
422 \end{lstlisting}
423 allows to change the text shown in the legend for element type \option{type}. The legend
424 is automatically translated to German if \textit{ngerman} is set with the babel package.
425
426 \begin{lstlisting}
427 \addlegendentry{(*\option{text}*)}{(*\option{style}*)}
428 \end{lstlisting}
429 adds a custom entry to the legend. The style of the legend image can set with
430 \option{style}. All style options for a tikz node are allowed. All custom legend entries
431 appear below the normal entries.
432
433
434
435
436
437
438 \subsection{Labels}
439 \label{sec:labels}
440 Every element has a text label showing the given element name. The position and
441 orientation of the label is set automatically according to the current angle of the
442 beamline. Several commands to modify the labels manually are described below. If you want
443 to disable labels, leave the element names blank or set the label color (section
444 \ref{sec:colors}) to your background color.
445
446 \begin{lstlisting}
447 \turnlabels
448 \end{lstlisting}
449 moves labels to other side of elements (swap with marker labels), while
450 \begin{lstlisting}
451 \northlabels
452 \southlabels
453 \end{lstlisting}
454 explicitly sets the labels to north or south (see section \ref{sec:remarks}) of the
455 elements. It is recommended to use these and not \lstinline+\turnlabels+, because
456 otherwise the label position at a certain element is determined by the number of
457 \lstinline+\turnlabels+ commands before this element.
458
459 \begin{lstlisting}
460 \rotatelabels{(*\option{angle/deg}*)}[(*\optiondef{anchor}{}*)]
461 \end{lstlisting}
462 allows rotation of element labels.
463 The \optiondef{anchor}{} sets the center of rotation (north, center, south west,
464 \ldots{}). West corresponds to the labels first character. By default the anchor is set
465 automatically depending on the current angle of the beamline.
466
467 \begin{lstlisting}
468 \begin{labeldistance}{(*\option{distance/m}*)}
469 ...
470 \end{labeldistance}
471 \end{lstlisting}
472 sets the distance of text labels to the element center for all elements within this
473 environment. Default is 0.35.
474
475 \begin{lstlisting}
476 \setlabeldistance{(*\option{distance/m}*)}
477 \resetlabeldistance
478 \end{lstlisting}
479 sets the distance of text labels to the element center for all following elements. the
480 reset command sets the default value. Default is 0.35.
481
482 \begin{lstlisting}
483 \setlabelfont{(*\option{fontsize}*)}
484 \end{lstlisting}
485 sets the text label font size. Default is \lstinline+\normalsize+.
486
487
488
489 \subsection{Colors}
490 \label{sec:colors}
491 The colors can be changed at any point of the lattice. A setting is valid until the next
492 color command. The reset commands set the according default color. Use a \lstinline+scope+
493 environment to change a color for a section of a lattice.
494
495 \begin{lstlisting}
496 \setlinecolor{(*\option{type}*)}{(*\option{color}*)}
497 \resetlinecolor{(*\option{type}*)}
498 \end{lstlisting}
499 for \option{type} drift and marker.
500
501 \begin{lstlisting}
502 \setelementcolor{(*\option{type}*)}{(*\option{color}*)}[(*\optiondef{gradient color}{white}*)]
503 \resetelementcolor{(*\option{type}*)}
504 \end{lstlisting}
505 for all element types. Set \optiondef{gradient color}{white} equal to \option{color} to
506 "disable" the gradient.
507
508 \begin{lstlisting}
509 \setlabelcolor{(*\option{color}*)}
510 \end{lstlisting}
511 for textlabels. Set to background color to hide text labels.
512
513
514
515 \subsection{Fade Out}
516 \label{sec:fade-out}
517
518 \begin{lstlisting}
519 \begin{fade}[(*\optiondef{opacity}{0.25}*)]
520 ...
521 \end{fade}
522 \end{lstlisting}
523 reduces the opacity of all elements within the environment and sets all colors to gray.
524 So you can fade out regions of the lattice - e.g. for presentations.
525 This can also be used to completely hide regions by setting \optiondef{opacity}{0.25} to
526 zero.
527
528 Custom drawings and annotations (see section \ref{sec:coords}) can also be faded out
529 automatically. The tikz style \lstinline{faded} provides the appropriate settings: Add
530 \lstinline{faded} to the style of any tikz drawing or node within the \lstinline{lattice}
531 environment. If it is drawn within a \lstinline{fade} environment, it is faded out. Else
532 its style is not changed:
533
534 \begin{minipage}[c]{0.6\textwidth}
535 \begin{lstlisting}
536 \begin{lattice}
537 \tikzset{mynode/.style={
538 anchor=west,xshift=7mm,font=\bf,red}}
539 \setangle{-90}
540 \drift{0.2}
541 \sextupole{S1}{0.2}
542 \drift{0.267}
543 \begin{fade}[0.4]
544 \quadrupole{Q1}{0.4}
545 \savecoordinate{Q1}[center]
546 \node[mynode,faded] at (Q1) {a quadrupole!};
547 \drift{0.29}
548 \end{fade}
549 \kicker{VC1}{0.1}
550 \savecoordinate{kick}[center]
551 \node[mynode,faded] at (kick) {a kicker!};
552 \drift{0.2}
553 \dipole{M1}{0.8}{30}
554 \drift{0.29}
555 \end{lattice}
556 \end{lstlisting}
557 \end{minipage}
558 %
559 \begin{minipage}[c]{0.4\textwidth}
560 \begin{center}
561 \begin{lattice}
562 \tikzset{mynode/.style={anchor=west,xshift=7mm,font=\bf,red}}
563 \setangle{-90}
564 \drift{0.2}
565 \sextupole{S1}{0.2}
566 \drift{0.267}
567 \begin{fade}[0.4]
568 \quadrupole{Q1}{0.4}
569 \savecoordinate{Q1}[center]
570 \node[mynode,faded] at (Q1) {a quadrupole!};
571 \drift{0.29}
572 \end{fade}
573 \kicker{VC1}{0.1}
574 \savecoordinate{kick}[center]
575 \node[mynode,faded] at (kick) {a kicker!};
576 \drift{0.2}
577 \dipole{M1}{0.8}{30}
578 \drift{0.29}
579 \end{lattice}
580 \end{center}
581 \end{minipage}
582
583
584 \clearpage
585 \subsection{Access lattice Coordinates}
586 \label{sec:coords}
587 You can use element coordinates to draw anything you want using pgf/tikz.
588
589 \begin{lstlisting}
590 \savecoordinate{(*\option{name}*)}[(*\optiondef{position}{east}*)]
591 \end{lstlisting}
592 saves the coordinate of the previous element to access it later. Position specifies the
593 exact place of the element. \textit{east} and \textit{center} are available (see section
594 \ref{sec:remarks}).
595
596 \begin{itemize}
597 \item you can use all tikz/pgf commands within the lattice environment to draw anything.
598 \item You can use this to connect multiple beamlines \textbf{within a lattice environment} with
599 \lstinline+\goto{name}+ (recommended, Figure \ref{fig:twoways} (a)).
600 \item You can use this to connect \textbf{multiple lattice environments} with
601 \lstinline+\start{name}+. Use the tikz overlay option. (Figure \ref{fig:twoways} (b))
602 \end{itemize}
603
604
605
606
607 \begin{figure}[h]
608 \centering
609 \begin{subfigure}[b]{.45\textwidth}
610 \centering
611 \begin{lattice}[0.8]
612 \rotate{90}
613 \turnlabels %labels to the left
614 \drift{0.5}
615 \quadrupole{QF1}{0.3}
616 \drift{0.2}
617 \kicker{}{0.1}
618 \drift{0.07}
619 \quadrupole{QD2}{0.3}
620 \drift{0.4}
621 \setelementcolor{kicker}{cyan}
622 \kicker{Septum}{0.5}
623 \resetelementcolor{kicker}
624 \savecoordinate{Septum}[center] %save to connect other beamline
625 \drift{0.8}
626 \kicker{}{0.1}
627 \drift{0.37}
628 \quadrupole{QD3}{0.2}
629 \drift{0.17}
630 \kicker{}{0.1}
631 \drift{0.1}
632 \sextupole{SF1}{0.2}
633 \drift{0.27}
634 \dipole{MB1}{0.2}{30}[s][0.4]
635 \drift{0.2}
636
637 % now go back to saved coordinate and continue with another beamline
638 \goto{Septum}
639 \rotate{-20}
640 \turnlabels %labels to the right
641 \drift{0.6}
642 \kicker{SS1}{0.2}
643 \drift{0.2}
644 \kicker{SSH1}{0.2}
645 \drift{0.3}
646 \dipole{M1}{0.2}{-30}[r][0.4]
647 \begin{fade} %fade out this part
648 \drift{0.2}
649 \dipole{M2}{0.2}{50}[r][0.4]
650 \drift{0.2}
651 \dipole{M3}{0.2}{-20}[r][0.4]
652 \drift{0.7}
653 \end{fade}
654 \legend{(0,6.5)}
655 \end{lattice}
656 \caption{one lattice environment and goto}
657 \end{subfigure}
658 %
659 \begin{subfigure}[b]{.45\textwidth}
660 \centering
661 \begin{lattice}[0.8]
662 \rotate{90}
663 \turnlabels %labels to the left
664 \drift{0.5}
665 \quadrupole{QF1}{0.3}
666 \drift{0.2}
667 \kicker{}{0.1}
668 \drift{0.07}
669 \quadrupole{QD2}{0.3}
670 \drift{0.4}
671 \setelementcolor{kicker}{cyan}
672 \kicker{Septum}{0.5}
673 \resetelementcolor{kicker}
674 \savecoordinate{Septum}[center] %save to connect other beamline
675 \drift{0.8}
676 \kicker{}{0.1}
677 \drift{0.37}
678 \quadrupole{QD3}{0.2}
679 \drift{0.17}
680 \kicker{}{0.1}
681 \drift{0.1}
682 \sextupole{SF1}{0.2}
683 \drift{0.27}
684 \dipole{MB1}{0.2}{30}[s][0.4]
685 \drift{0.2}
686 \end{lattice}
687 %
688 %now draw second lattice and connect them using the saved coordinate
689 \begin{lattice}[0.8][overlay]
690 \start{(Septum)}
691 \rotate{70}
692 \drift{0.6}
693 \kicker{SS1}{0.2}
694 \drift{0.2}
695 \kicker{SSH1}{0.2}
696 \drift{0.3}
697 \dipole{M1}{0.2}{-30}[r][0.4]
698 \begin{fade} %fade out this part
699 \drift{0.2}
700 \dipole{M2}{0.2}{50}[r][0.4]
701 \drift{0.2}
702 \dipole{M3}{0.2}{-20}[r][0.4]
703 \drift{0.7}
704 \end{fade}
705 \legend{(-1,6.5)}
706 \end{lattice}
707 \caption{two lattice environments and start}
708 \end{subfigure}
709 \caption{From example 3: Two ways to connect lattices}
710 \label{fig:twoways}
711 \end{figure}
712
713
714
715 \clearpage
716 \section{Changelog}
717 \label{sec:changelog}
718 v2.1 from 2015/02/23 is the first published version.
719
720 \paragraph{v2.2 from 2015/03/01}
721 \begin{itemize}
722 \item added \lstinline+\northlabels+ and \lstinline+\southlabels+
723 \item minor legend improvements (label position is now independent of current lattice settings)
724 \item minor documentation improvements
725 \end{itemize}
726
727 \paragraph{v2.21 from 2015/03/18}
728 \begin{itemize}
729 \item added \lstinline+faded+ style (apply fade out to custom annotations)
730 \item fixed sector dipole drawing
731 \item documentation fixes
732 \end{itemize}
733
734 \paragraph{v2.3 from 2017/03/09}
735 \begin{itemize}
736 \item added \lstinline+\setlegendtext+ and \lstinline+\addlegendentry+
737 \item German legend translation via babel (\textit{ngerman})
738 \item legend fixes
739 \end{itemize}
740
741
742 \section{TODO}
743 \label{sec:todo}
744
745 \paragraph{What is missing?}
746 \begin{itemize}
747 \item The look of the elements can be improved
748 \item More element types can be added
749 \item \ldots{}
750 \end{itemize}
751
752 I am not an \TeX{} programmer. I basically used the \tikzlabel{} commands and wrote a
753 bunch of macros. So there is:
754 \begin{itemize}
755 \item no error handling implemented
756 \item no dedicated scoping of internal macros (use of lattice with documentclass standalone recommended)
757 \end{itemize}
758
759 \paragraph{Known issues:}
760 \begin{itemize}
761 \item A circular lattice can have a significant offset (no closed circle), if the dipole
762 bending angles are not integer. Probably, this is due to rounding or calculation
763 accuracy.
764 \item Please report bugs!
765 \end{itemize}
766
767 \end{document}