seven wolves

This is a place to organize myself.
正文

latex tips

(2010-03-29 09:08:45) 下一個
http://www.dd.chalmers.se/latex/tips_e.html#subfig

Here are some hints on how to get nicer documents.

Using compressed eps figures in a document
Two figures side by side
Convert dvi files to pdf
Colors
Source code, e.g. Matlab
How to place figures where you want them
Other fonts
Changing the margins
Change page numbering
Really large letters
Greater space between lines in tables
Not ready to give up FrameMaker?
Degrees celsius
New paragraph
Abstract in two languages
How to write technical text
Swedish and Englisg keyboard in emacs
Figures/tables inside the text
Comma instead of decimal point

Using compressed eps figures in a document
If you have a large picture that takes up a lot of space on your account, you can compress it using gzip and then include it in your document. If you have a picture called pic.eps, you do like this:
Copy the row in pic.eps that begins with %%BoundingBox to a new file called pic.eps.bb. Then compess the picture using the gzip command:
gzip pic.eps
Include the picture in your LATEX document like this:
begin{figure}[!ht]centeringincludegraphics[width=10cm]{pic.eps.gz}caption{A compressed picture.}end{figure}

Two figures side by side
To place to figures side by side, you could use minipage like this:
begin{figure}begin{minipage}[b]{0.5linewidth} % A minipage that covers half the pagecenteringincludegraphics[width=6cm]{bild1.eps}caption{En liten bild}end{minipage}hspace{0.5cm} % To get a little bit of space between the figuresbegin{minipage}[b]{0.5linewidth}centeringincludegraphics[width=6cm]{bild2.eps}caption{En liten bild till}end{minipage}end{figure}
With minipage, you get two different figures. Another way to do it is to use the package subfigure (usepackage{subfigure} in the preamble). You will then get two subfigures inside one figure.
begin{figure}centeringsubfigure[Bild a.] % caption for subfigure a{    label{fig:sub:a}    includegraphics[width=4cm]{bild_a.eps}}hspace{1cm}subfigure[Bild b.] % caption for subfigure b{    label{fig:sub:b}    includegraphics[width=4cm]{bild_b.eps}}caption{Bild a och b.}label{fig:sub} % caption for the whole figureend{figure}
When you use subfigure you only get one figure, i.e figure 3. When you refer to the subfigures, they are called figure 3(a) and figure 3(b).

Convert dvi files to pdf
To generate a pdf file from a dvi file, use the program dvipdfm like this:
dvipdfm dvi_file.dvi
Read the manual!

Colors
Use the package color. Here's a short example of how to use it:
documentclass{article}usepackage[latin1]{inputenc} % Fixa 邃?usepackage{color}definecolor{pink}{rgb}{1,0.5,0.5} % color values Red, Green, Bluebegin{document}pagecolor{black} % Background colorcolor{white}     % Text colorI think I'm in textcolor{rosa}{love} with LaTeX.end{document}

Source code, e.g. Matlab
Use the package moreverb to include a whole text file instead of useing begin{verbatim}. A short example ([8] means that the tab size is eight characters):
documentclass{article}usepackage[latin1]{inputenc} % Fixa 邃?usepackage{moreverb}begin{document}And the interesting source code:verbatimtabinput[8]{pdesolve.m}end{document}

How to place figures where you want them
The package here has been removed from CTAN. Instead you should use a ! in front of the positioning parameter. I.e:
documentclass{article}usepackage[latin1]{inputenc} % Fixa 邃?usepackage{here}usepackage{graphicx}begin{document}begin{figure}[!h] % Will not be floating.  begin{center}  includegraphics{graph.eps}  caption{Exciting graph}  end{center}end{figure}end{document}

Other fonts
The following fonts are installed at dd: palatino, times, charter, utopia, pifont, chancery, bookman, avant, helvet(ica), zapfchan(cery), courier, newcent(ury schoolbook) and computer modern.

There are also special versions of palatino and times -- pspalatino --> -- och pslatex, which also changes the font in all the formulas to --> -- palatino or times. Take a look at the -- HREF=Templates/rapportmall.tex>report template to see how to --> -- use them (usepackage{font name}).

Change the margins
The easiest way to change the margins in the document is to use the package anysize and its command marginsize{left}{right}{top}{bottom}:
documentclass[a4paper]{article}usepackage{anysize}marginsize{3cm}{2cm}{1cm}{1cm}begin{document}Jawohl! Sommerlov!end{document}

Change page numbering
If you want to change the page numbering anywhere in your document, e.g. to make sure that the first page in the report is actually page one, you can use setcounter{page}{1} (anywhere on the page you want to be named 1.)

Really large letters
Use the package textfit and the commands scaletoheight{height}{text} and scaletowidth{width}{text}:
documentclass[a4paper]{article}usepackage{textfit}begin{document}scaletoheight{3 cm}{Large!}scaletowidth{10 cm}{Large}\scaletowidth{10 cm}{But this is the same width!}end{document}

Greater space between lines in tables
Crowded tabels? The command \ actually has an option. If you, for example, write \[.3cm] you will get a 0.3 cm space in your table. You could also use the package tabls, usepackage{tabls}.

Not ready to give up FrameMaker?
Well, there are some ways to make your documents look better. In the directory /users/dd/sys/http/data/latex/Templates/FrameMaker there are some ''mif'' files that you can use. Check the README and in latex-style.framemif for some help. It's a kind of template that is supposed to make your document a bit more like LATEX.

Degrees Celsius
To get a nice degree character, use the packgae usepackage{textcomp} and the command textcelsius. There's also textangle for angles.

New paragraph
There are two ways of starting a new paragraph, either with an empty line or by indenting the first line in the new paragraph (in the LATEX source file you use an empty line as always.) If you want every new paragrapg to start with an empty line, put the lines below before begin{document}):
setlength{parskip}{12pt}  % 12 pt = space between paragraphssetlength{parindent}{0pt} % 0 pt  = indentation

Abstract
If you want your abstract in two languages, e.g. Swedish and English, you can use usepackage{swedish}, usepackage{english} and then
begin{document}selectlanguage{swedish}begin{abstract}  Detta 鋜 en kort sammanfattning.end{abstract}begin{otherlanguage}{english}  begin{abstract}    This is a short abstract.  end{abstract}end{otherlanguage}

How to write technical text
Take a look at the American Physical Society's Style and Notation Guide.

Swedish and English keyboard in emacs
If you want to use ? ? ?in your document you don't have to switch to Swedish keyboard. Just use /A "A "O /a "a "o and let emacs translate them with M-x iso-accents-mode.

Figures/tables inside the text
Sometimes you don't want a figure or table to use the whole width of the page. You can then use usepackage{wrapfig} and you will get the environments begin{wrapfigure}[A]{B}[C]{D} ... end{wrapfigure} och begin{wraptable}[A]{B}[C]{D} ... end{wraptable} d鋜
  • A - Not necessary. Number of lines to be made shorter.
  • B - Necessary. Placing: r, l, i, o, R, L, I, O where capitals=floating figure, lower case=figure HERE, r=right, l=left, i=inside, o=outside.
  • C - Not necessary. How far the figure should stretch into the margin..
  • D - Necessary. Width of figure.

Comma instead of decimal point
If you write $3,14$ you will get the wrong spacing in LATEX because the comma is not a decimal deliminator. To fix it, write the following in the beginning of your document:
DeclareMathSymbol{,}{mathpunct}{letters}{"3B}DeclareMathSymbol{.}{mathord}{letters}{"3B}DeclareMathSymbol{decimal}{mathord}{letters}{"3A}
And $f(x,y,z)=3.14$ will be output as "f(x, y, z) = 3,14".
More on the way...
[ 打印 ]
閱讀 ()評論 (0)
評論
目前還沒有任何評論
登錄後才可評論.