Feeds:
Posts
Comments

Archive for the ‘Special Typeset’ Category

On \parskip

I must copy this answer from tex.se. It is really useful. I often change \parskip and always find the lists look awful.


The main reason why “playing with \parskip is a bad idea” is that this length also affects list environments. Quoting from Mittelbach (1989), With LateX into the Nineties, section 3.1 “Implementation desasters”:

The generic list environment is one of the central modules of the LaTeX implementation. It is used internally by most standard environments provided by LaTeX; even environments such as center are handled as a special kind of list […]

  • An actual conceptual bug was the decision to add the value of \parskip to all vertical spacing parameters, even when it is used in places where no paragraph ends. This means that changing this parameter influences the layout in unexpected places, which in turn means that other parameters must be adjusted unnecessarily to compensate for this undesired side effect.

The last sentence describes what the parskip package, the options of the same name of theKOMA-script classes and the \abnormalparskip macro of the memoir class do: Besides setting \parskip to a positive value (and, with the exception of memoir, setting \parindentto zero), they adjust the spacing before and after lists.

Why does KOMA-scripthave so many options for parskip? You may choose between a vertical space equal to \baselineskip (full) or 0.5\baselineskip (half). You may also choose the minimum amount of whitespace to be left at the end of the last line of a paragraph (up to0.33\linewidth); such whitespace increases the perceptibility of the start of a new paragraph.

Regarding \parindent: As Ulrike has explained, changing this length is not a problem.

Read Full Post »

Typesetting numerical data (with units) in LaTeX correctly can be difficult and time-consuming. Note that I emphasized “correctly.”

Fortunately, siunitx comes to the rescue. From its description:

Typesetting values with units requires care to ensure that the combined mathematical meaning of the value plus unit combination is clear. In particular, the SI units system lays down a consistent set of units with rules on how they are to be used. However, different countries and publishers have differing conventions on the exact appearance of numbers (and units). A number of LaTeX packages have been developed to provide consistent application of the various rules: SIunits, sistyle, unitsdef and units are the leading examples. The numprint package provides a large number of number-related functions, while dcolumn and rccol provide tools for typesetting tabular numbers.

The siunitx package takes the best from the existing packages, and adds new features and a consistent interface. A number of new ideas have been incorporated, to fill gaps in the existing provision. The package also provides backward-compatibility with SIunits, sistyle, unitsdef and units. The aim is to have one package to handle all of the possible unit-related needs of LaTeX users.

Some examples stolen from its manual:

  • \num{1+-2i} produces 1 \pm 2\text{i}
  • \num{.3e45} produces 0.3 \times 10^{45}
  • \si{kg.m.s^{-1}} or \si{\kilogram\metre\per\second} both produce \text{kg}\,\text{m}\,\text{s}^{-1}
  • \si[per-mode=symbol]{\kilogram\metre\per\second} produces \text{kg}\,\text{m} / \text{s}

These are just a few examples. The possibility is much larger and the package is very useful. So keep my words: “Always use siunitx when possible.”

Read Full Post »

Today I got an weird error:

! TeX capacity exceeded, sorry [input stack size=1500].

The error text is not very helpful (not at all), but the compiler stopped at a section command of the form:

\section{Some text $\bm{d}$}

So I searched on Google and found the cause of the error. It was caused by hyperref trying to convert the mathematical expressions and symbols in the section title to a PDF link in the table of contents. Somehow hyperref does not like mathematical text in section titles, especially bold symbols. There are several solutions, but the following two are the easiest:

  • Specify an alternative title for the section, usually called short title, and hyperref will use that for the link, like this:

    \section[Some text d]{Some text $\bm{d}$}

  • Specify pure text alternatives for the special symbols in the title, like this:

    \section{Some text \texorpdfstring{$\bm{d}$}{d}}

Note that the same error can happen with not only mathematical symbols but also other special fonts, such as \verb (as some people reported).

References:

Read Full Post »

Two LaTeX packages are very popularly used to typeset algorithms/pseudo-code (actually one is a set of related packages). The first is the algorithms package and its related packages. The second is the algorithm2e package.

The algorithms package provides two basic environments: algorithm for creating floats that contain algorithms, and algorithmic for typesetting actual algorithms. It is very straightforward and easy to use, however it is not flexible and does not provide ways to customize the output easily. The algorithmicx package provides the same algorithmic environment, but with greater flexibility.

The algorithm2e package provides environments for typesetting algorithms with ultimate flexibility. By default, the output looks very much like actual code. It is very customizable. However, it is more difficult to use, and its syntax is not very intuitive.

My advice:

  • If you don’t need to customize the output of your algorithms too much, don’t have very special needs, or just want to typeset your algorithms quickly, go with the algorithms family.
  • If you need very professionally looking algorithms, or you want to customize the output in a very special way, then you may want to go with algorithm2e (just MAY).

P.S: google the package name on CTAN and you will find the package. I didn’t put the links here.

Read Full Post »

The original article is at stackexchange: http://tex.stackexchange.com/q/10122/3048

The blkarray package can be found on CTAN.

Read Full Post »

The CV Inn is a very excellent resource for writing CV’s with LaTeX.

Read Full Post »

cool is a package that helps mathematical equations in LaTeX more meaningful. Also, it makes writing equations easier, especially those involve a lot of (high-order) derivatives, partial derivatives, etc. The name cool stands for COntent Oriented LaTeX. The only concern is that this package is not very popular, so it should be avoided if you want to share your LaTeX files with many people, or if you want to submit your files to a publisher who forbids non-standard packages.

Read Full Post »

LaTeX is not only excellent for writing technical and science documents  but also for writing other types of documents, including letters. You probably know that. If you don’t, you can learn more about it here, or read the documentation for the ‘letter’ document class. There is one concern though, that is how to add a digital signature (i.e., an image of your signature) to the letter. This post explains how to do that, although I found that it did not work correctly on my system. The following worked for me: remove the standard \signature and \closing commands and use:

Sincerely yours,\\[\medskipamount]  % The closing
\includegraphics[scale=0.4]{my_signature}\\[\medskipamount]
\fromsig

You may want to change the vertical space amount and the scale of your signature image. The command \fromsig will include your name.

In the case you still want to print the letter out and sign it in ink, but you find the default space is too small, this is a tip for enlarging the signature space.

\setlength{\oldmedskipamount}{\medskipamount}
\addtolength{\medskipamount}{2\medskipamount}
\closing{The closing, such as: Best regards,}
\setlength{\medskipamount}{\oldmedskipamount}

Read Full Post »

One common composition in typesetting mathematical formulas in LaTeX is stacking mathematical symbols, sometimes quite long, over an arrow. Standard LaTeX provides several commands for this purpose, however sometimes they do not satisfy our need, especially when we typeset long arrows. In this post, I will review several commands that will help you to typeset all kinds of math-symbol-over-arrows.

It is assumed that the amsmath package is included.

Typeset arrows in LaTeX

Most types of arrows are provided in LaTeX. The most commonly used are summarized in the following table.

\leftarrow \leftarrow
\Leftarrow \Leftarrow
\rightarrow \rightarrow
\Rightarrow \Rightarrow
\leftrightarrow \leftrightarrow
\Leftrightarrow \Leftrightarrow
\longleftarrow \longleftarrow
\Longleftarrow \Longleftarrow
\longrightarrow \longrightarrow
\Longrightarrow \Longrightarrow
\longleftrightarrow \longleftrightarrow
\Longleftrightarrow \Longleftrightarrow
\leadsto \leadsto
\implies \implies
\iff \iff
\to \to
\gets \gets

Generic stacking commands

To stack mathematical symbols over or under other mathematical symbols, not necessarily arrows, you can use the following commands.

  1. \stackrel{top}{bottom}: stack top (script style) over bottom. Example:
    a\stackrel{\epsilon}{\longrightarrow}b gives a\stackrel{\epsilon}{\longrightarrow}b
    but a\stackrel{\rm{this is very long text}}{\longrightarrow}b gives a\stackrel{\text{this is very long text}}{\longrightarrow}b which is not what we want.
  2. Using \overset{top}{main-symbol} and \underset{bottom}{main-symbol}: examples
    a\overset{x}{\longrightarrow}b gives a\overset{x}{\longrightarrow}b
    a\underset{x}{\longrightarrow}b gives a\underset{x}{\longrightarrow}b
    but a\overset{\text{this is very long text}}{\longrightarrow}b gives ugly result a\overset{\text{this is very long text}}{\longrightarrow}b.
  3. Using \mathop{main-symbol}_{bottom}^{top} to typeset mathematical operators with top and bottom symbols. Example:
    a\mathop{\sum\sum\sum}_{a=\frac12}^{\text{some text}}b gives

    a\mathop{\longrightarrow}^{\epsilon}b gives

    but a\mathop{\longrightarrow}^{\text{this is very long text}}b gives
    .

Stack mathematical symbols over sizable arrows

When the top or bottom symbols are too long, the above commands give unsatisfying results. Amsmath provides two commands to typeset sizable arrows, i.e. arrows whose lengths extend to the lengths of the top and/or bottom matters. These commands are \xleftarrow[bottom]{top} and \xrightarrow[bottom]{top}. Examples:

a\xrightarrow[\alpha]{\epsilon}b gives a\xrightarrow{\epsilon}b

a\xrightarrow{\text{This is very long text}}b gives a\xrightarrow{\text{This is very long text}}b

Another use of these commands

a\xrightarrow{\hspace*{3cm}}b gives a\xrightarrow{\hspace*{3cm}}b

References:

http://elevatorlady.ca/doc/refcard/expressions.html

http://nw360.blogspot.com/2008/07/stack-math-symbols.html

Read Full Post »

Typesetting CV’s in LaTeX

Update on October 26, 2011.

Some useful resources that I found on the Internet:

  • This page compiles a list of useful links for writing CV in LaTeX.
  • This one is a resume class for LaTeX, ready to be used. It looks quite pretty and professional. However, there is one thing I don’t really like, that is the years are kind of in the middle of the page. I tend to like them to be either on the right margin (like most examples below) or the left margin (like the moderncv one).
  • This page has several examples of CV in LaTeX, both for academia and industry. The samples look detailed and professional (not fancy). They use the standard LaTeX document class (article) and standard packages, and customize them for a CV. This is just a template, not a class or package.
  • This one is a fairly standard CV, a bit too standard. It uses article class and other standard packages, and customize them. This is just a template, not a class or package.
  • This one is also a customized CV based on the standard article class. It looks a bit similar to the moderncv one (with years on the left) but less pretty.
  • On CTAN, there are several packages for writing CV, for example moderncv and CurVe. They are both easy to use and can produce pretty and professional CV. However, if you want to customize your CV beyond what are provided, it may be a bit difficult.
  • CV in LaTeX with beautiful fonts: this one focuses on fonts and pretty typesetting for CV. Somehow when I used these fonts, the output could not be viewed on some browsers. So be careful.

 

Read Full Post »

Older Posts »