atex and graphics - university of...

1
L A T E X and graphics Zofia Walczak Uniwersytet L´odzki,Poland When T E X was written, PostScript/eps, jpeg, gif, and other graphic formats did not exist. As a result, Knuths dvi format does not have direct support for imported graphics. However, T E X allows dvi files to contain \special commands which pass commands to programs which use dvi files. This allowed T E X and L A T E X to import any graphic format which was supported by the dvi program being used. Inserting eps graphics in L A T E X originally required the low-level \special command. To make graphic-insertion easier and more portable, two higher-level packages epsf and psfig were written for L A T E X2.09. With the release of L A T E X2e in 1994, the L A T E X3 team addressed the general problem of inserting graphics in L A T E X. Their efforts produced the “L A T E X graphics bundle” which contains totally re-written commands that are more efficient, more robust, and more portable than other graphics-insertion commands. The graphics bundle contains the “standard” graphics package and the “extended”. Just as the latex command uses T E X to process L A T E X documents into dvi files, the command pdflatex uses pdftex to process L A T E X documents directly into pdf files. An important aspect of pdfT E X is its native inclusion of a variety of graphics formats: jpeg, png, pdf, MetaPost. Although older versions of pdftex supported native inclusion of tiff files, the current version of pdftex does not support tiff. Note that pdftex can not directly import eps files, which requires users with eps files to use a program like epstopdf which converts eps files to pdf format, although this prevents the direct use of psfrag. Some current T E X implementations (like T E XLive 2012/2013) support conversion eps-to-pdf “on a fly”. L A T E X picture environment The picture environment is used to draw pictures composed of text, straight lines, arrows and circles. The objects in the picture are positioning by specifying their coordinates. The basic syntax for the environment is: \begin{picture}(width,height)(x-offset,y-offset) picture commands \end{picture} Everything that appears in a picture is drawn by the \put command. \begin{picture}(10,8) \includegraphics{1.jpg} \put(-4,4)% {\includegraphics{2.jpg}} \put(-6,5){\Large $\bullet$} \end{picture} The \put(1,2){obj} command puts the object specified by obj in the picture, with the reference point at coordinates (1,2). Remark: The tex file can be compiled with latex and pdflatex. PSfrag package The psfrag package allows L A T E X users to replace text strings in eps files with L A T E X text or equations. To use psfrag, create an eps file and then perform the following steps I Include \usepackage{psfrag} in the preamble of the L A T E X document. I In the document, use the \psfrag command to specify the eps text to replace and the L A T E X string to replace it. This makes the specified substitution occur in any subsequent \includegraphics command issued in the same environment. I Use the \includegraphics command as usual. The L A T E X \psfrag command has the following syntax \psfrag{PStext}[posn][PSposn][scale][rot]{text} Pictures are taken from [8]. D d C q C d q D Figure : Contact of Δ with a projection of a Hopf torus of F 0 . \begin{figure} \psfrag{d}{$\delta$} \psfrag{D}{$\Delta$} \psfrag{q}{$q_0$} \psfrag{C}{Contact} \includegraphics{AA.eps} \end{figure} Figure : Contact of Δ with a projection of a Hopf torus of F 0 . Remark: PSfrag cannot be used with pdfT E X. If psfrag substitution is needed, one option is to use the L A T E X-to-dvi-to-PostScript-to-pdf route that was used before pdfT E X. PSfrag doesn’t work with beamer. When preparing presentation with beamer one can use Tik Z package instead (eps figure should be converted to pdf format). MusiXT E X MusiXT E X is a set of macros and fonts which enables music typesetting within the T E X system. MusiXT E X might be regarded as the digital equivalent of a box of type. It contains symbols for staves, notes, chords, beams, slurs and ornaments, ready to be arranged to form a sheet of music. But it must be told how to position those symbols on the page. This could be done by the typesetter himself, if he elects to proceed by entering MusiXT E X commands manually into an input file. However most users will find it far less taxing to let such decisions be made largely by the preprocessor PMX, which in addition uses a much simpler input language than MusiXT E X. Small fragment of code: {\mtxTitle}{2.0}{\mtxPoetComposer}{2.0}\en% % Bar count 1 \pnotes{2.00}\ibl1{’E}0\qb1C\qb1G\qb1E\tbl1\qb1G\ibl1E0\qb1C\qb1G\qb1E% \tbl1\qb1G|\hl{’c}\sk\sk\sk\ql e\sk\ql g\en% % Bar count 2 \xbar \pnotes{2.00}\ibl1{’F}0\qb1D\qb1G\qb1F|\qlp{’b}\en% \pnotes{1.41}\tbl1\qb1{’G}|\ibbl2{’c}2\qb2c\tbl2\qb2d\en% \pnotes{2.00}\ibl1{’E}0\qb1C\qb1G\qb1E\tbl1\qb1G|\hl{’c}\en% Remark: MusiXT E X needs eL A T E X which is automatically invoke when is needed but in general L A T E X and MusiXT E X does not collaborate. For typesetting a large musical score is better to use T E X. amscd package The amscd package provides a CD environment that emulates the commutative diagram capabilities of A M S T E X version 2.x. This means that only simple rectangular diagrams are supported, with no diagonal arrows or more exotic features. Diagram is taken from [4]. $$ \CD A_{PL}(Y) @>>> A_{PL}(X) @>>> A_{PL}(F)\\ @A{m_Y}AA @A{m}AA @A{\bar m}AA\\ (\Lambda V_Y,d) @>>> (\Lambda V_Y\otimes\Lambda V,d) @>>> (\Lambda V,\bar d) \endCD $$ Remark: The amscd package does not collaborate with beamer class. chemfig package This is the T E X package for drawing molecules. The most important command for drawing molecules is \chemfig{<code>}. The argument code is a set of characters describing the structure of the molecule according to the rules which are described in this manual. The command \chemfig draws a molecule using the commands provided by the Tik Z package, placed inside a tikzpicture environment. Glucose, skeleton diagram HO OH OH OH OH O H |\chemfig{[:-30]HO--[:30](<[2]OH)-(<:[6]OH) -[:30](<:[2]OH)-(<:[6]OH)-[:30](=[2]O)-H}| Remark:The current maintainer of this package is Christian Tellechea. The package can be used with latex and pdflatex, there are some problems with compilation in beamer class. X Y -pic package X Y -pic is a general-purpose drawing package based on T E X. It works smoothly with most formats, including L A T E X, A M S -L A T E X, A M S -T E X, and plain T E X. It has been used to typeset complicated diagrams from numerous application areas, including category theory, automata, algebra, geometry, neural networks, and knot theory. X Y -diagram from [2]. K /H // K /H // K /H Γ \ G /H // M /H // BH B Γ b // M /K f // BK \xymatrix{ K/H \ar[r] \ar[d]& K/H \ar[r] \ar[d]& K/H \ar[d]\\ \varGamma\setminus G/H \ar[r] \ar[d]&M/H\ar[r] \ar[d]&BH \ar[d]\\ B\varGamma \ar[r]^b& M/K \ar[r]^f & BK} More sophisticated X Y -diagram from [1]. Y z y ++ x A f // g l ## B s B {{ p B ;; k 0 B C p $$ $$ C s C :: p C zz h // q ++ D r Q TikZ – a frontend of pgf package A frontend is a set of commands or a special syntax that makes using the basic layer easier. The Tik Z frontend is the “natural” frontend for pgf. It gives you access to all features of pgf, but it is intended to be easy to use. The syntax is a mixture of metafont and pstricks and some ideas of the author. The pgf package, where “pgf” is supposed to mean “portable graphics format” is a package for creating graphics in an “inline” manner. Comparison with other graphics packages. I The Tik Z syntax is more consistent than the pstricks syntax. I The X Y -pic package is an older package for creating graphics. I The xfig program is an important alternative to Tik Z for users who do not wish to “program” their graphics as is necessary with Tik Z and X Y -pic. Examples One can use Tik Z for: 1. adding mathematical symbols to the picture prepared by external program (picture from [8]) \begin{tikzpicture} \node [anchor=south west] at (0,0) { \includegraphics{XY.jpg}}; \node at (4.6,3.5) {$c$}; \node at (9,5.3) {$\Sigma_1$}; \node at (-0.05,5.5) {$\Sigma_2$}; \node at (6.5,5) {$C_1$}; ... \end{tikzpicture} 2. drawing diagrams A - B B C D \begin{tikzpicture} \node[rectangle,draw] (b1) at (5,0){$A-B$}; \node[rectangle,draw] (b2) [right=of b1] {B}; \node[rectangle,draw] (b3) [right=of b2] {C}; \draw[->](b1.east)--(b2.west)(b2.east)--(b3.west); \node[circle,draw] (b4) [below=of b2] {D}; \draw[>=latex,->] (b1.south)--(b4.west); \draw[->] (b4.east) .. controls +(right:5mm) and +(down:10mm) .. (b3.south west); \end{tikzpicture} 3. drawing bar diagrams \begin{tikzpicture}[ycomb,scale=4] \draw[color=red,line width=1cm] plot coordinates{(0,1) (.6,1.2) (1.2,.6) (1.8,.7) (2.4,.9)}; \draw[color=red!50,line width=1cm, xshift=4pt] plot coordinates{(0,1.2) (.6,1.3) (1.2,.5) (1.8,.2) (2.4,.5)}; \draw[color=blue,line width=1cm, xshift=8pt] plot coordinates{(0,1.4) (.6,1.1) (1.2,.4) (1.8,.5) (2.4,1)}; \end{tikzpicture} 4. some graphics for students: x y r 1 1 · α B(y , 0) O(0, 0) A(x , 0) P(x , y ) R h r l x y For plotting functions Tik Z use external program gnuplot N 2 N 1 A small part of code \draw[color=red] (0,5) .. controls (1.4,2.3) .. (2.8,2) node[pos=.50]{\rotatebox{35}{$\wedge$}}; \draw[color=green] (0,5) .. controls (1.5,1.5) .. (3.5,1) node[pos=.55]{\rotatebox{35}{$\wedge$}}; 5. ... and for fun ·· Bibliography F. Borceux, Handbook of Categorical Algebra 2: Categories and Structures, Cambridge University Press, 1994. ´ S. Gal, J. K¸edra and A. Tralle, On the algebraic independence of Hamiltonian characteristic classes, J. Sympl. Geom., 9 (2011), 1–9. M. Goossens, S. Ratz and F. Mittelbach, L A T E X Graphics Companion, Addison-Wesley, 1999. B. Hajduk and A. Tralle, On simply connected K -contact non Sasakian manifolds, to appear. H. Kopka and P.W. Daly, A Guide to L A T E X2e, Addison-Wesley, 1995. L. Lamport, L A T E X: A Document Preparation System, Addison-Wesley Publishing Company, 1986. L. Lamport, L A T E X: A Document Preparation System, Wydawnictwa Naukowo-Techniczne, Warszawa 2004 (in Polish). R. Langevin and J-C Sifre, Foliations of S 3 by Dupin cyclides, to appear. E. Rafajlowicz and W. Myszka, L A T E X, Zaawansowane Narz¸edzia, Akad. Ofic. Wydawn. PLJ, Warszawa, 1996 (in Polish). K. Reckdahl, Using Imported Graphics in LATEX and pdfLATEX, CTAN/macros/latex/required/graphics/grfguide.ps Z. Walczak, L A T E X for Impatient, Wydawn. Uniwersytetu odzkiego, 2012 (in Polish). Geometry and Foliatiation 2013, September 9–14, Komaba, Tokyo, Japan

Upload: dangphuc

Post on 07-Mar-2018

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ATEX and graphics - University of Tokyogf2013.ms.u-tokyo.ac.jp/poster_session/Walczak_Zofia_20130905.pdf · LATEX and graphics Zo a Walczak Uniwersytet L odzki, Poland When TEX was

LATEX and graphicsZofia Walczak

Uniwersytet Lodzki, PolandWhen TEX was written, PostScript/eps, jpeg, gif, and other graphic formats did not exist. As a result,Knuths dvi format does not have direct support for imported graphics. However, TEX allows dvi files tocontain \special commands which pass commands to programs which use dvi files. This allowed TEXand LATEX to import any graphic format which was supported by the dvi program being used. Insertingeps graphics in LATEX originally required the low-level \special command. To make graphic-insertioneasier and more portable, two higher-level packages epsf and psfig were written for LATEX2.09.With the release of LATEX2e in 1994, the LATEX3 team addressed the general problem of inserting graphicsin LATEX. Their efforts produced the “LATEX graphics bundle” which contains totally re-written commandsthat are more efficient, more robust, and more portable than other graphics-insertion commands.

The graphics bundle contains the “standard” graphics package and the “extended”.Just as the latex command uses TEX to process LATEX documents into dvi files, the commandpdflatex uses pdftex to process LATEX documents directly into pdf files.An important aspect of pdfTEX is its native inclusion of a variety of graphics formats: jpeg, png,pdf, MetaPost. Although older versions of pdftex supported native inclusion of tiff files, thecurrent version of pdftex does not support tiff. Note that pdftex can not directly import eps files,which requires users with eps files to use a program like epstopdf which converts eps files to pdf

format, although this prevents the direct use of psfrag. Some current TEX implementations (likeTEXLive 2012/2013) support conversion eps-to-pdf “on a fly”.

LATEX picture environmentThe picture environment is used to draw pictures composed of text,straight lines, arrows and circles. The objects in the picture are positioningby specifying their coordinates.The basic syntax for the environment is:

\begin{picture}(width,height)(x-offset,y-offset)

picture commands

\end{picture}

Everything that appears in a picture is drawn by the \put command.

••

\begin{picture}(10,8)

\includegraphics{1.jpg}

\put(-4,4)%

{\includegraphics{2.jpg}}

\put(-6,5){\Large $\bullet$}

\end{picture}

The \put(1,2){obj} command puts the object specified by obj in thepicture, with the reference point at coordinates (1,2).

Remark: The tex file can be compiled with latex and pdflatex.

PSfrag packageThe psfrag package allows LATEX users to replace text strings in eps files with LATEX text or equations. To use psfrag, create an eps file andthen perform the following steps

I Include \usepackage{psfrag} in the preamble of the LATEX document.

I In the document, use the \psfrag command to specify the eps text to replace and the LATEX string to replace it. This makes the specifiedsubstitution occur in any subsequent \includegraphics command issued in the same environment.

I Use the \includegraphics command as usual.

The LATEX \psfrag command has the following syntax \psfrag{PStext}[posn][PSposn][scale][rot]{text}

Pictures are taken from [8].

Dd

C

q

C

d

q

D

Figure : Contact of ∆ with a projection ofa Hopf torus of F0.

\begin{figure}

\psfrag{d}{$\delta$}

\psfrag{D}{$\Delta$}

\psfrag{q}{$q_0$}

\psfrag{C}{Contact}

\includegraphics{AA.eps}

\end{figure}Figure : Contact of ∆ with a projection ofa Hopf torus of F0.

Remark: PSfrag cannot be used with pdfTEX. If psfrag substitution is needed, one option is to use the LATEX-to-dvi-to-PostScript-to-pdf routethat was used before pdfTEX. PSfrag doesn’t work with beamer. When preparing presentation with beamer one can use TikZ package instead(eps figure should be converted to pdf format).

MusiXTEXMusiXTEX is a set of macros and fonts which enables music typesettingwithin the TEX system. MusiXTEX might be regarded as the digitalequivalent of a box of type. It contains symbols for staves, notes,chords, beams, slurs and ornaments, ready to be arranged to form asheet of music. But it must be told how to position those symbols onthe page. This could be done by the typesetter himself, if he elects toproceed by entering MusiXTEX commands manually into an input file.However most users will find it far less taxing to let such decisions bemade largely by the preprocessor PMX, which in addition uses a muchsimpler input language than MusiXTEX.

Small fragment of code:

{\mtxTitle}{2.0}{\mtxPoetComposer}{2.0}\en%

% Bar count 1

\pnotes{2.00}\ibl1{’E}0\qb1C\qb1G\qb1E\tbl1\qb1G\ibl1E0\qb1C\qb1G\qb1E%

\tbl1\qb1G|\hl{’c}\sk\sk\sk\ql e\sk\ql g\en%

% Bar count 2

\xbar

\pnotes{2.00}\ibl1{’F}0\qb1D\qb1G\qb1F|\qlp{’b}\en%

\pnotes{1.41}\tbl1\qb1{’G}|\ibbl2{’c}2\qb2c\tbl2\qb2d\en%

\pnotes{2.00}\ibl1{’E}0\qb1C\qb1G\qb1E\tbl1\qb1G|\hl{’c}\en%

Remark: MusiXTEX needs eLATEX which is automatically invoke whenis needed but in general LATEX and MusiXTEX does not collaborate. Fortypesetting a large musical score is better to use TEX.

amscd packageThe amscd package provides a CD environment that emulates thecommutative diagram capabilities of AMSTEX version 2.x. This meansthat only simple rectangular diagrams are supported, with no diagonalarrows or more exotic features.Diagram is taken from [4].

$$

\CD

A_{PL}(Y) @>>> A_{PL}(X)

@>>> A_{PL}(F)\\

@A{m_Y}AA @A{m}AA

@A{\bar m}AA\\

(\Lambda V_Y,d) @>>>

(\Lambda V_Y\otimes\Lambda V,d)

@>>> (\Lambda V,\bar d)

\endCD

$$

Remark: The amscd package does not collaborate with beamerclass.

chemfig packageThis is the TEX package for drawing molecules. The most importantcommand for drawing molecules is \chemfig{<code>}. The argumentcode is a set of characters describing the structure of the moleculeaccording to the rules which are described in this manual. Thecommand \chemfig draws a molecule using the commands providedby the TikZ package, placed inside a tikzpicture environment.

Glucose, skeleton diagram

—HO

OH

OH

OH

OH

O

H

— |\chemfig{[:-30]HO--[:30](<[2]OH)-(<:[6]OH)

-[:30](<:[2]OH)-(<:[6]OH)-[:30](=[2]O)-H}|

Remark:The current maintainer of this package is Christian Tellechea.The package can be used with latex and pdflatex, there are someproblems with compilation in beamer class.

XY-pic packageXY-pic is a general-purpose drawing package based on TEX. It workssmoothly with most formats, including LATEX, AMS-LATEX, AMS-TEX,and plain TEX. It has been used to typeset complicated diagrams fromnumerous application areas, including category theory, automata,algebra, geometry, neural networks, and knot theory.

XY-diagram from [2].

K/H //

��

K/H //

��

K/H

��

Γ \ G/H //

��

M/H //

��

BH

��

BΓ b //M/K f //BK\xymatrix{

K/H \ar[r] \ar[d]&

K/H \ar[r] \ar[d]&

K/H \ar[d]\\

\varGamma\setminus G/H

\ar[r] \ar[d]&M/H\ar[r]

\ar[d]&BH \ar[d]\\

B\varGamma \ar[r]^b&

M/K \ar[r]^f & BK}

More sophisticatedXY-diagram from [1].

Yz

��

y

++

x

��

��

A f //

��

g

��

l##

BsB

{{

pB

;;

k

��

0

��

B ⊕ Cp

$$ $$

C

sC::

pCzz

h//

q++

Dr

Q

TikZ – a frontend of pgf packageA frontend is a set of commands or a special syntax that makes usingthe basic layer easier. The TikZ frontend is the “natural” frontend forpgf. It gives you access to all features of pgf, but it is intended to beeasy to use. The syntax is a mixture of metafont and pstricks

and some ideas of the author.The pgf package, where “pgf” is supposed to mean “portable graphicsformat” is a package for creating graphics in an “inline” manner.

Comparison with other graphics packages.

I The TikZ syntax is more consistent than the pstricks syntax.

I The XY-pic package is an older package for creating graphics.

I The xfig program is an important alternative to TikZ for users who do not wishto “program” their graphics as is necessary with TikZ and XY-pic.

ExamplesOne can use TikZ for:1. adding mathematical symbols to the picture prepared by externalprogram (picture from [8])

\begin{tikzpicture}

\node [anchor=south west] at (0,0) {

\includegraphics{XY.jpg}};

\node at (4.6,3.5) {$c$};

\node at (9,5.3) {$\Sigma_1$};

\node at (-0.05,5.5) {$\Sigma_2$};

\node at (6.5,5) {$C_1$};

. . .

\end{tikzpicture}

2. drawing diagrams

A− B B C

D

\begin{tikzpicture}

\node[rectangle,draw] (b1) at (5,0){$A-B$};

\node[rectangle,draw] (b2) [right=of b1] {B};

\node[rectangle,draw] (b3) [right=of b2] {C};

\draw[->](b1.east)--(b2.west)(b2.east)--(b3.west);

\node[circle,draw] (b4) [below=of b2] {D};

\draw[>=latex,->] (b1.south)--(b4.west);

\draw[->] (b4.east) .. controls +(right:5mm)

and +(down:10mm) .. (b3.south west);

\end{tikzpicture}

3. drawing bar diagrams\begin{tikzpicture}[ycomb,scale=4]

\draw[color=red,line width=1cm]

plot coordinates{(0,1) (.6,1.2) (1.2,.6)

(1.8,.7) (2.4,.9)};

\draw[color=red!50,line width=1cm,

xshift=4pt]

plot coordinates{(0,1.2) (.6,1.3)

(1.2,.5) (1.8,.2) (2.4,.5)};

\draw[color=blue,line width=1cm,

xshift=8pt]

plot coordinates{(0,1.4) (.6,1.1)

(1.2,.4) (1.8,.5) (2.4,1)};

\end{tikzpicture}

4. some graphics for students:

x

y

r

•1

1

· α

B(y , 0)

O(0, 0)A(x , 0)

P(x , y)

R

h

r

l

x

y

For plotting functions

TikZ use external

program gnuplot • N2

N1

∧∧∧

∧∧

A small part of code\draw[color=red] (0,5) .. controls (1.4,2.3)

.. (2.8,2)

node[pos=.50]{\rotatebox{35}{$\wedge$}};

\draw[color=green] (0,5) .. controls (1.5,1.5)

.. (3.5,1)

node[pos=.55]{\rotatebox{35}{$\wedge$}};

5. . . . and for fun · ·

Bibliography

F. Borceux, Handbook of Categorical Algebra 2: Categories and Structures, Cambridge University Press, 1994.

S. Gal, J. Kedra and A. Tralle, On the algebraic independence of Hamiltonian characteristic classes, J. Sympl.Geom., 9 (2011), 1–9.

M. Goossens, S. Ratz and F. Mittelbach, LATEX Graphics Companion, Addison-Wesley, 1999.

B. Hajduk and A. Tralle, On simply connected K -contact non Sasakian manifolds, to appear.

H. Kopka and P.W. Daly, A Guide to LATEX2e, Addison-Wesley, 1995.

L. Lamport, LATEX: A Document Preparation System, Addison-Wesley Publishing Company, 1986.

L. Lamport, LATEX: A Document Preparation System, Wydawnictwa Naukowo-Techniczne, Warszawa 2004 (inPolish).

R. Langevin and J-C Sifre, Foliations of S3 by Dupin cyclides, to appear.

E. Rafaj lowicz and W. Myszka, LATEX, Zaawansowane Narzedzia, Akad. Ofic. Wydawn. PLJ, Warszawa, 1996 (inPolish).

K. Reckdahl, Using Imported Graphics in LATEX and pdfLATEX,CTAN/macros/latex/required/graphics/grfguide.ps

Z. Walczak, LATEX for Impatient, Wydawn. Uniwersytetu Lodzkiego, 2012 (in Polish).

Geometry and Foliatiation 2013, September 9–14, Komaba, Tokyo, Japan