miktex and advanced latex
TRANSCRIPT
12
/department of mathematics and computer science 1/75
MiKTEX and advanced LATEXDay 1
Marko Boon
October 3, 2006
12
/department of mathematics and computer science 2/75
Part 1: programs on the TU/e MiKTEX CD-ROM:
• WinEdt
• Yap
• GSView
• MiKTEX Package Manager
• MiKTEX Options
• Designer
• create graphics and include them in your LaTeX document
12
/department of mathematics and computer science 3/75
Part 2: LATEX for experienced users
• customising list structures
• automatic calculation of column widths
• use non-standard headers and footers
• change chapter and section title appearance
• change table of contents appearance
• create an interactive PDF file from your LaTeX document
• create a master index
• citations and a bibliography
• including programming statements in your LaTeX document
• create a PDF slide show or poster
• Using TrueType Fonts in LATEX
12
/department of mathematics and computer science 4/75
WinEdt - Working with a main file
In bigger documents one often has onemain file which includes several sub-documents: \input chapter1 etc.. WinEdt has special functionality todeal with this document structure:
declares the current file as main file. This means that the programslatex, yap, dvips, gsview, pdflatex operate on this mainfile, even if another document is opened in WinEdt.
does not consider the current file as main file anymore. The file that iscurrently open will be LATEXed.
displays the project tree (main file, input files, table of contents, bibliog-raphy and labels. You can click on files in this tree to open them.
12
/department of mathematics and computer science 5/75
WinEdt - Working with a main file
12
/department of mathematics and computer science 6/75
WinEdt - Working with a main file
12
/department of mathematics and computer science 7/75
Installing additional packages
Two ways to install additional packages:
1. MiKTEX Package Manager(in the MiKTEX program group in the Start Menu)
2. automatic package installation (since MiKTEX 2.4)
12
/department of mathematics and computer science 8/75
MiKTEX Package Manager
12
/department of mathematics and computer science 9/75
MiKTEX Package Manager
12
/department of mathematics and computer science 10/75
MiKTEX Package Manager
12
/department of mathematics and computer science 11/75
MiKTEX Package Manager
12
/department of mathematics and computer science 12/75
Automatic Package Installation
12
/department of mathematics and computer science 13/75
Automatic Package Installation
12
/department of mathematics and computer science 14/75
Automatic Package Installation
12
/department of mathematics and computer science 15/75
Automatic Package Installation
12
/department of mathematics and computer science 16/75
LATEX search path
1. local TEXmf tree: C:\MiKTeX\localtexmf
2. standard TEXmf tree: C:\MiKTeX\texmf
12
/department of mathematics and computer science 17/75
LATEX search path
Adding your own TEXmf tree:
1. create a directory that contains the root of your TEXmf tree(e.g. C:\My Documents\LaTeX)
2. create a subdirectory tex and copy all your style files into this directory
3. optional: create a subdirectory fonts and copy all your font files into thisdirectory
4. start MiKTEX Options ( button in WinEdt)
5. add your directory to the TEXmf Root Directories and move it to the topof the list
12
/department of mathematics and computer science 18/75
LATEX search path
12
/department of mathematics and computer science 19/75
LATEX search path
12
/department of mathematics and computer science 20/75
LATEX search path
12
/department of mathematics and computer science 21/75
LATEX search path
12
/department of mathematics and computer science 22/75
LATEX search path
12
/department of mathematics and computer science 23/75
LATEX search path
12
/department of mathematics and computer science 24/75
LATEX search path
Each time you add a file to your TEXmf tree, you have to refresh the file namedatabase:
12
/department of mathematics and computer science 25/75
Graphics
Two ways to make pictures:
Using LATEX, epic and eepic drawingcommands:
��
��
���
���
��
����
Warning: eepic is not supported byPDFLATEX.
Include external graphics files (EPS,PDF, JPG, PNG):
1
2
3
4
5
Pressure
1
2
3
4
Temp
0
10
20
30
Response
1
2
3
4ressure
0
10
20
3
12
/department of mathematics and computer science 26/75
LATEX Graphics
Load the packages epic and/or eepic. Then create drawing objects in a pic-ture environment.
\setlength{\unitlength}{1cm}\begin{picture}(6,6)\thicklines\put(1,1){\grid(4,4)(1,1)}\drawline(3,2)(4,3)(3,4)(2,3)(3,2)\put(3,3){\circle{2}}\end{picture}
You can use the program JFig (xfig in Unix/Linux) to create eepic or EPSfigures.
12
/department of mathematics and computer science 27/75
JFig (similar to xfig)
12
/department of mathematics and computer science 28/75
JFig (similar to xfig)
12
/department of mathematics and computer science 29/75
JFig (similar to xfig)
12
/department of mathematics and computer science 30/75
Graphics Inclusion
To include an external graphics file:
• Load the package graphicx in the preamble:
\usepackage{graphicx}
• Include the graphics using this command:
\includegraphics[width=0.7\linewidth]{filename}
12
/department of mathematics and computer science 31/75
Graphics Inclusion
Supported File Formats:EPS PDF JPG GIF PNG
LATEX yes no yes∗ no yes∗
PDFLATEX no yes yes no yes
Please notice: only EPS and PDF are scalable. Use JPG and PNG just forphotographs!
Many programs can generate EPS images. Use Corel Designer to exportimages created in other programs. Copy/Paste the objects in Corel Designerand export to EPS.
Use EPS2PDF (on your desktop) to convert EPS to PDF.
∗ does not work automatically when working with LATEX. You should enterthe coordinates of the bounding box manually.
12
/department of mathematics and computer science 32/75
Graphics Inclusion
\includegraphics[options]{filename}
When including EPS or PDF files, use the file name without extension!LATEX will take the EPS, PDFLATEX will take the PDF.
Supported options are:
scale=number magnifies the figure by number over its natural size.
width=length specifies the width to which the figure should be scaled
height=length specifies the height to which the figure should be scaled
angle=number rotates the figure counterclockwise over the specified an-gle (in degrees)
bb=llx lly urx ury enters the coordinates of the bounding box manually.
12
/department of mathematics and computer science 33/75
Scalable and non-scalable graphics
O
P
Q
������6
7 ����������6
1
1
12
/department of mathematics and computer science 34/75
Scalable and non-scalable graphics
P
������6
1Scalable graphics formats:EPS, PDF, WMF, EMF, SVG.
Non-scalable graphics formats:JPG, GIF, BMP, PNG.But also: all scalable formats!
12
/department of mathematics and computer science 35/75
Scalable Graphics Software
• Corel Designer,
• CorelDraw,
• Adobe Illustrator,
• Microsoft Visio,
• Microsoft Office Drawing,
• OpenOffice.org Draw,
• all computer algebra software (Mathematica, Matlab, Maple)
Non-scalable Graphics Software
• Adobe PhotoShop,
• Paint Shop Pro,
• MS Paint,
• all digital photo editing software!
12
/department of mathematics and computer science 36/75
Including JPG/PNG Images
LATEX (unlike PDFLATEX) cannot determine the bounding box automatically.
JPEG Image, 2304 × 1728 pixels,taken with 4.0 megapixel digital cam-era
\includegraphics[width=8cm,bb=0 0 2304 1728]{images/holiday.jpg}
12
/department of mathematics and computer science 37/75
Corel Designer
12
/department of mathematics and computer science 38/75
Corel Designer
12
/department of mathematics and computer science 39/75
Corel Designer
12
/department of mathematics and computer science 40/75
Creating EPS graphics with OpenOffice.org
OpenOffice.org is an alternative to Microsoft Office.Advantages:
• You can download it for free: http://www.openoffice.org.
• It is compatible with Microsoft Office (supports Word, Excel and EMFfiles).
• Has EPS and PDF export functionality, but it still contains some bugs(some text “disappears”)
In fact, the only programmodule that we need, is Openoffice.org Draw (andthe graphics filters).
12
/department of mathematics and computer science 41/75
Creating EPS graphics with Adobe PostScript Driver
• download Adobe PostScript Printer Driver fromhttp://www.adobe.com/support/downloads/.
• installation settings:
– directly connected to computer (local printer)
– port: FILE:
• to create an EPS file, print to this printer
• in printer properties, advanced options, select PostScript Output Option:Encapsulated PostScript (EPS)
• select a filename (add .ps extension!)
• open GSView and select File−→ PS to EPS
• Select “automatically calculate bounding box” and press Yes.
12
/department of mathematics and computer science 42/75
Creating EPS graphics with Adobe PostScript Driver
12
/department of mathematics and computer science 43/75
Creating EPS graphics with Adobe PostScript Driver
12
/department of mathematics and computer science 44/75
Creating EPS graphics with Adobe PostScript Driver
12
/department of mathematics and computer science 45/75
Creating EPS graphics with Adobe PostScript Driver
12
/department of mathematics and computer science 46/75
Creating EPS graphics with Adobe PostScript Driver
12
/department of mathematics and computer science 47/75
Creating EPS graphics with Adobe PostScript Driver
12
/department of mathematics and computer science 48/75
Creating EPS graphics with Adobe PostScript Driver
12
/department of mathematics and computer science 49/75
Creating EPS graphics with Adobe PostScript Driver
12
/department of mathematics and computer science 50/75
Creating EPS graphics with Adobe PostScript Driver
12
/department of mathematics and computer science 51/75
Creating EPS graphics with Adobe PostScript Driver
12
/department of mathematics and computer science 52/75
Creating EPS graphics with Adobe PostScript Driver
12
/department of mathematics and computer science 53/75
Creating EPS graphics with Adobe PostScript Driver
12
/department of mathematics and computer science 54/75
Creating EPS graphics with Adobe PostScript Driver
12
/department of mathematics and computer science 55/75
Inline floats
The package wrapfig makes it possible to place text next to floats:
\begin{wrapfigure}{placement}[overhang]{width}\includegraphics[width=\linewidth]{image}\end{wrapfigure}
placement horizontal placement: l (left) or r (right). For two-sided docu-ments: i (inside edge) or o (outside edge).
overhang overhang of the float into the margin (default: 0pt).
width width of the figure or table (use wraptable for tables).
12
/department of mathematics and computer science 56/75
Two floats next to each other
1. No caption
\includegraphics[width=0.45\linewidth]{images/pic1}\hfill\includegraphics[width=0.45\linewidth]{images/pic2}
1
2
3
4
5
Pressure
1
2
3
4
Temp
0
10
20
30
Response
1
2
3
4ressure
0
10
20
3
1
2
3
4
5
Pressure
1
2
3
4
Temp
0
10
20
30
Response
1
2
3
4ressure
0
10
20
3
12
/department of mathematics and computer science 57/75
Two floats next to each other
2. One caption
\begin{figure}[ht]\includegraphics[width=0.45\linewidth]{images/pic1}\hfill\includegraphics[width=0.45\linewidth]{images/pic2}\caption{a response surface.}\label{fig:surface}\end{figure}
12
/department of mathematics and computer science 58/75
Two floats next to each other
3. Two captions
Nowwe need the package caption. This package has very extensive function-ality to change the appearance of captions. In this case we are only going touse the new command \captionof.
\parbox[t]{0.45\textwidth}{\includegraphics[width=\linewidth]{pic1}\captionof{figure}{the first figure}
}\hfill\parbox[t]{0.45\textwidth}{
\includegraphics[width=\linewidth]{pic2}\captionof{figure}{the second figure}
}
For tables, just repace figure by table.
12
/department of mathematics and computer science 59/75
1
2
3
4
5
Pressure
1
2
3
4
Temp
0
10
20
30
Response
1
2
3
4ressure
0
10
20
3
Figure 2: the first figure
1
2
3
4
5
Pressure
1
2
3
4
Temp
0
10
20
30
Response
1
2
3
4ressure
0
10
20
3
Figure 3: the second figure
12
/department of mathematics and computer science 60/75
Two floats next to each other
4. Sub-captions
Now we need the package subfig:
\begin{figure}[ht]\begin{center}\subfloat[First figure]{
\includegraphics[width=0.45\textwidth]{pic1}}\subfloat[Second figure]{
\includegraphics[width=0.45\textwidth]{pic2}}\caption{Two figures}\end{center}\end{figure}
12
/department of mathematics and computer science 61/75
1
2
3
4
5
Pressure
1
2
3
4
Temp
0
10
20
30
Response
1
2
3
4ressure
0
10
20
3
1
2
3
4
5
Pressure
1
2
3
4
Temp
0
10
20
30
Response
1
2
3
4ressure
0
10
20
3
Figure 1: a response surface.
12
/department of mathematics and computer science 62/75
1
2
3
4
5
Pressure
1
2
3
4
Temp
0
10
20
30
Response
1
2
3
4ressure
0
10
20
3
(a) First figure
1
2
3
4
5
Pressure
1
2
3
4
Temp
0
10
20
30
Response
1
2
3
4ressure
0
10
20
3
(b) Second figure
Figure 4: Two figures
12
/department of mathematics and computer science 63/75
PSfrag – Inserting LATEX code in EPS graphics
• Use the includegraphics command defined by the graphicx packages toadd EPS figures to your new documents.
• Load the psfrag package with a usepackage command.
• Make sure that your EPS figures contain a simple “tag” word in eachposition that you would like a LATEX replacements. Use a single word,composed of unaccented letters and numbers.
• For each tag word in your EPS file, add a command to your your LATEXdocument to specify how this tag is to replaced, as follows:
\psfrag{tag}[posn][psposn][scale][rot]{LATEX text}
The tag will be replaced by the LATEX text.
12
/department of mathematics and computer science 64/75
PSfrag – Example
12
/department of mathematics and computer science 65/75
PSfrag – Example
t
0
0.2
0.4
0.6
0.8
1
1.2
0.2
0.8
1.4 2
2.6
3.2
3.8
4.4 5
5.6
6.2
x
y s
12
/department of mathematics and computer science 66/75
PSfrag – Example
\psfrag{t}{The chart of $\displaystyle\sqrt{\left|\frac{\sin x}{x}\right|}$}\psfrag{s}{$\sin x$}\psfrag{x}{$x$}\psfrag{y}{$\sin x$}
\includegraphics[width=0.8\textwidth]{sinxx}
12
/department of mathematics and computer science 67/75
PSfrag – Example
0
0.2
0.4
0.6
0.8
1
1.2
0.2
0.8
1.4 2
2.6
3.2
3.8
4.4 5
5.6
6.2
The chart of
√∣∣∣∣sin x
x
∣∣∣∣
sin x
x
sin
x
12
/department of mathematics and computer science 68/75
PSfrag – Example
0
0.2
0.4
0.6
0.8
1
1.2
0.2
0.8
1.4 2
2.6
3.2
3.8
4.4 5
5.6
6.2
The chart of
√∣∣∣∣sin x
x
∣∣∣∣
sin x
x
sin
x
12
/department of mathematics and computer science 69/75
PSfrag – Example
0
0.2
0.4
0.6
0.8
1
1.2
0.2
0.8
1.4 2
2.6
3.2
3.8
4.4 5
5.6
6.2
The chart of
√∣∣∣∣sin x
x
∣∣∣∣sin x
x
sin
x
12
/department of mathematics and computer science 70/75
PSfrag – To get it right!
Step 1: create larger and wider labels
12
/department of mathematics and computer science 71/75
PSfrag – To get it right!
Step 2: create the EPS file with Adobe PS printer and open in in WinEdt
%!PS-Adobe-3.0 EPSF-3.0%%Title: Book1%%Creator: PScript5.dll Version 5.2.2%%CreationDate: 2/2/2005 16:58:15%%For: mboon%%BoundingBox: 56 455 447 718%%Pages: 1%%Orientation: Portrait%%PageOrder: Ascend%%DocumentNeededResources: (atend)%%DocumentSuppliedResources: (atend)%%DocumentData: Clean7Bit%%TargetDevice: (Generic PostScript Printer) (2010.0)%%LanguageLevel: 2
12
/department of mathematics and computer science 72/75
PSfrag – To get it right!
Step 3: search for the label(s)
1174 1241 M (5.6)[17 -16 8 -8 0 0]zS; : 1235 1167 86 86 rc F1S1DIFFFFFFE2 Ji1267 1241 M (6.2)[17 -16 8 -8 0 0]zS; /F0S2A F0 [42 0 0 -42 0 0 ] mFSF0S2A Ji859 1303 M (x)S: N 1391 745 377 195 rp C1 1 1 1 scol L ; 1 Lw solid N 1768 744 M 1390 744 IK0 0 0.5 1 scol 4 Lw solid N 1433 850 M 1509 850 I :; 0 0 0 1 scol /F1S75 F1 [117 0 0 -117 0 0 ] mFSF1S75 Ji1536 887 M (sinx)[59 26 65 0]xS0 Lj : 150 267 1657 1126 rc N 1776 284 M 167 284 I: [ 1 0 0 1 150 267 ] concat K
12
/department of mathematics and computer science 73/75
PSfrag – To get it right!
Step 4: remove all text between (label) and next S
1174 1241 M (5.6)S; : 1235 1167 86 86 rc F1S1DIFFFFFFE2 Ji1267 1241 M (6.2)S; /F0S2A F0 [42 0 0 -42 0 0 ] mFSF0S2A Ji859 1303 M (x)S: N 1391 745 377 195 rp C1 1 1 1 scol L ; 1 Lw solid N 1768 744 M 1390 744 IK0 0 0.5 1 scol 4 Lw solid N 1433 850 M 1509 850 I :; 0 0 0 1 scol /F1S75 F1 [117 0 0 -117 0 0 ] mFSF1S75 Ji1536 887 M (sinx)S0 Lj : 150 267 1657 1126 rc N 1776 284 M 167 284 I: [ 1 0 0 1 150 267 ] concat K
12
/department of mathematics and computer science 74/75
PSfrag – To get it right!
Step 5: create psfrag replacements in LATEX code.
\psfrag{t}{\makebox[0cm]{The chart of$\displaystyle\sqrt{\left|\frac{\sin x}{x}\right|}$}}\psfrag{sinx}{$\displaystyle\sqrt{\left|\frac{\sin x}{x}\right|}$}\psfrag{x}{$x$}\psfrag{y}{$\sin x$}\psfrag{0}{$0$}\psfrag{0.2}{$0.2$}
...
\psfrag{1}{$1$}\psfrag{1.2}{$1.2$}
\includegraphics[width=\textwidth]{sinxxx}
12
/department of mathematics and computer science 75/75
PSfrag – To get it right!
The chart of
√∣∣∣∣sin x
x
∣∣∣∣
√∣∣∣∣sin x
x
∣∣∣∣
x
sin
x
0
0.2
0.2
0.8
0.8
1.4 2
2.6
3.2
3.8
4.4 5
5.6
6.2
0.4
0.6
1
1.2