CTAN lion drawing by Duane Bibby

Optimising the scientific writing: TeX-related tips and tricks

 

Inverse/Forward search

is a capability of LaTeX editor and LateX previewer to establish a cross-talk (synchronising their current position via special marks embedded in the dvi-file). Generally, this is brought about by the option -src or --src of a LaTeX compiler. See How to enrich your document with source specials, Inverse Search between Kile and KDVI, and Forward Search between Kile and KDVI for details.

Configuration of Kile & KDVI

KDVI configuration
  1. Go to menu  Settings -> Configure KDVI -> DVI Specials;
  2. Select (if it isn't yet chosen) [Editor]:  Kile.
Kile configuration
  1. Go to menu  Settings -> Configure Kile... -> Tools -> Build -> LateX;
  2. Change [Select a Configuration]:  Modern;
  3. Add  -src-special=cr,display,hbox,math,par,vbox  to the [Options] field, so that it looks like
    -src -src-special=cr,display,hbox,math,par,vbox -interaction=nonstopmode '%source'.
That's it. How does it work? Inverse search (KDVI->Kile): to make the editor jumped on a desired position, click at it in KDVI with the middle mouse button. To make a forward search (Kile->KDVI) place cursor at a required piece of text in Kile and click the [ForwardDVI] button (top-right corner of the toolbars).

Configuration of TeXnicCenter/WinEdt & Yap

Yap configuration
  1. Go to menu  View -> Options -> Inverse Search;
  2. Edit [Command Line]:  C:\Program Files\TeXnicCenter\TEXCNTR.EXE /ddecmd "[goto('%f', '%l')]"
    or, if you use WinEdt, you need only select [Program]:  WinEdt.
TeXnicCenter configuration
  1. Go to menu  Build -> Define Output Profiles...;
  2. For each profile (LaTeX=>DVI, LaTeX=>PS, etc.) add --src in the [Command line arguments to pass to the compiler], so that it looks like
    --src -interaction=nonstopmode "%Wm".
WinEdt configuration
By default, WinEdt automatically adds --src option at compillation. You can check if it turns on by the presence of "--src" caption on the bottom status line, on the right to the "TeX" caption. It is activated and deactivated by clicking at that cell.
But if something fails to work, or you just want an unconditional insertion of the source marks
  1. go to menu  Options -> Execution Modes...;
  2. for each desired mode from the left column (LaTeX, TeXify, etc.) add --src to [Command line: Switches], so that it looks like
    --src %0.
That's it. How does it work? Inverse search: to make the editor jumped on a desired position, double-click it in Yap. Forward search should automatically synchronise your current cursor position in the editor with the Yap preview at the moment of compilation.

 

[top]

TeX-Point

is an add-in for Microsoft PowerPoint that allows you to use the LaTeX source directly in your presentations. It works by converting any piece of TeX-code into an editable PNG-image, which is embedded into your presentation and does not require TeXPoint to be shown by any PowerPoint-aid machine. An advantage is that these are truly editable folmulas. A double-click on a TeXPoint created image opens its source code, which you can copy or modify as you wish.

Of course, there is no magic behind it. TeXPoint is just a front end for existing an LaTeX system (e.g. MiKTeX) and GhostScript , so you need them to be installed if they are not yet there.

The latest *free* version is TeXPoint2_7.zip. All newer versions of TeXPoint become shareware and can be found at TeXPoint.necula.org. Although the free version 2.7 (Oct 2005) provides most of the functionality required, it is slightly more difficult in installation and you are encouraged to thank the authors, George Necula and Andreas Glatz, by obtaining the latest TeXPoint version (shareware).

Installation of TeXPoint 2.7 (for MS PowerPoint XP/2003)

Note: You should have MiKTeX and GhostScript installed.
  1. Download and extract the archive TeXPoint2_7.zip (4.3 MByte) in a permanent directory (e.g. C:\Program Files\TeXPoint2_7\)
  2. Launch PowerPoint. Go to the menu [Tools] --> [Macro] --> [Security...] and set the Security Level to "Medium". Close PowerPoint and restart it again.
  3. Go to the menu [Tools] --> [Add-Ins...] and click on the button|Add New...|.
  4. In the appeared dialogue window browse to the TeXPoint directory (e.g. C:\Program Files\TeXPoint2_7\) and point to the file TeXPoint2_7_2003.ppa (if your attempt has failed, try TeXPoint2_7_win.ppa). In response to the warning message click on |Enable Macros|. Close the dialogue window. A new menu "TeXPoint" should appear in the menu row (top-right).
  5. Let GhostScript (gswin32c.exe) be installed in "C:\Program Files\gs\gs8.14\bin" and MikTeX (latex.exe) can be found in "C:\Program Files\MiKTeX 2.5\miktex\bin". Click on the icon "My Computer" at your Desktop with the Right-mouse-button. In the menu choose [Properties] --> [Advanced] and then click on |Environment Variables|.
  6. In the appeared window, in the section [System Variables] scroll the list until you see the row starting with "Path". Then click on |Edit| and add the paths to the GhostScript and LaTeX (e.g. C:\Program Files\gs\gs8.14\bin;C:\Program Files\MiKTeX 2.5\miktex\bin;) to the string WITHOUT ANY SPACES before or after and with a semicolon after.
    As a result, your string should look like C:\Program Files\gs\gs8.14\bin;C:\Program Files\MiKTeX 2.5\miktex\bin;%SystemRoot%\system32;....
    Save the changes and reboot the PC.

Try to open a sample presentation with TeXPoint formulae example.ppt and Double-Click on any image to edit it.

Some more technical help and examples can be found in "..\TeXPoint2_7\doc\" of the TeXPoint directory.

My advice is to avoid the usage of in-text TeXPoint's fonts in presentations. It is much more reliable to use the TeX display-mode instead. An example of the template is
 \documentclass[a4paper,12pt]{article}
 \usepackage{amssymb,amsmath,latexsym}
 \usepackage[usenames]{color}
 \pagestyle{empty}
   
 \begin{document}
 \begin{equation*}
   \begin{gathered}
   \color[rgb]{0,0,0}
     ...
     a^2 + b^2 = c^2
     ...
   \end{gathered}
\end{equation*}
\end{document}
 

 

[top]

JabRef - Universal BibTeX Bibliography Manager

  1. To import a bibliography file from Firefox directly to JabRef, create
    the following executable bash-script (for Linux users), say JabRef:
    #!/bin/sh
    java -jar /PATH_TO_JabRef/JabRef-2.6.jar --import $(readlink -f $1)

    then browse and select this script (or just JabRef.exe itself in MS Windows)
    with Open with... in Firefox each time when you encounter a .ris-file or the like.
    N.B. Do not forget to activate Preferences --> Advanced --> Remote Operation in JabRef.
  2. You can use the following sources of bibliography entries for importing directly to JabRef:
    1. Publishers (Elsevier, Springer, etc.)
      by using the options: Export Citation, Export this article as RIS, and so on;
    2. Google Scholar (go to Scholar Preferences --> Show links to import citations into BibTeX)
    3. World Library Catalogue (go to Cite/Export --> Export a Citation)
    4. And many-many others.
  3. To change the case of any field to, e.g. First capital only; First Capital In Each Word;
    all in lowercase or ALL IN UPPERCASE, right-click in the entry editor
    and choose the desired format from the menu Change case.
  4. To push references directly to Kile, using [LyX/Kile] button in JabRef:
    1. Create a new directory .lyx in your home folder;
    2. Go to JabRef menu Preferences -> External Programmes, click on the [LyX] button,
      enter /FULL_PATH_TO_HOME/.lyx/lyxpipe.in and save.
    Now launch Kile, place the cursor at a desired position in your document, select one or
    several references in JabRef, press [LyX/Kile] button and enjoy imported BibTeX keys.
  5. To automatically wrap all capital letters for certain fields in JabRef with { }
    (to make sure they are preserved in the LaTeX output), go to menu Options -> Preferences ->
    General -> File -> "Store the following fields with braces around capital letters"

    and include the desired fields, e.g. title;journal;author.
    This setting automatically adds braces when saving the .bib file, but you won't see the
    braces within JabRef (from jabref-users mailing-list).
  6. Formatting options for export filters are very flexible. For example, this
    \begin{author}\format[Authors(LastFirst,NoPunc,InitialsNoSpace),HTMLChars,Replace(A Name,<strong>A Name</strong>)]{\author}\end{author}
    would print an author list in a compact format with the author "A Name" shown in bold.
    Source: JabRef mailing list; see more details.
  7. To use the LibreOffice plug-in for literature export, install the java API package:
    sudo apt-get install libreoffice-java-common

    press Tools --> OpenOffice/LibreOffice Connection, click on [Manual Connect], and set 'path to executable' to
    /usr/lib/libreoffice/program/soffice.bin and 'path to library dir' to /usr/lib/libreoffice.

 

[top]

OOoLaTeX

is an extension (macros) for LaTeX support in OpenOffice. The latest version can be found on SourceForge:
prdownloads.sourceforge.net/ooolatex.

To install perform the following steps:

  1. go to menu Tools --> Extension Manager... --> Add and open OOoLatex-*.oxt file;
  2. restart OOffice.Writer; a new toolbar with three buttons (Equation, Expand and Config) should appear;
  3. click on [Config] on this new panel;
  4. Enter paths to LaTeX and GhostScript (in our School they are simply /usr/bin);
  5. Test the system: click [Equation], type something (e.g. e^{i\pi}=-1) and hit [LaTeX].
To edit any created formula, select it and click [Equation]. Enjoy!

Equations can be inserted as editable PNG images (use button [Equation]) or expanded into symbol characters.
You normally type in a formula in the pop-up editor window, select inline/display option and click on [Latex]
to generate the image. Alternatively, you can type directly in the main document, e.g. \frac{\alpha}{\beta} \ll 1,
press [Equation] and get the expression automatically converted to an image.
Consult http://ooolatex.sourceforge.net for more details.

 

[top]

LaTeX Tricks and Tips

  1. The Python-based computing environment SAGE allows for elaborate
    plotting capabilities inside the LaTeX-environment:
    \usepackage{sagetex}
    ...
    \sageplot[angle=30, width=5cm]{plot(sin(x), 0, pi), axes=False}

  2. To compare changes in two .tex-files use the following:
    latexdiff old.tex new.tex > diff.tex

    The perl-script latexdiff doing this is available at CTAN
    (sometimes it is necessary to use the script named latexdiff-so instead).
  3. One way to do word & character-count in a TeX file is to apply the ps2ascii
    utility to a generated .ps or .pdf as follows:
    ps2ascii file.pdf | wc

    The output consists of three figures. The first one is the number of lines,
    the second is the number of words and the last one is the number of
    characters (bytes).
  4. To deal with a hyperref package warning: Token not allowed in a PDFDocEncoded string...,
    provide alternative plain text for maths by using \texorpdfstring{$Your Formula$}{Equivalent Text}
    in \section{}, \subsection{}, etc. (see also other hyperref problems).
  5. To prevent Adobe PDF reader from errors like "Cannot extract the embedded font...",
    add the PDF-specific option -Ppdf to dvips command line (e.g. in Kile/WinEdt settings).
    Also, avoid using \usepackage[T1]{fontenc} but use {\fontencoding{T1}...} locally instead.
  6. To make a book/thesis-style PDF-document with discontinuous page-number navigation, like "page 10 (14 of 200)",
    ensure the following options are used in \usepackage[...]{hyperref}, NOT in the \hypersetup{...} :
    \usepackage[plainpages=false,pdfpagelabels]{hyperref}

    More Pdf/LaTeX-related help (see also the UK TeX FAQ and TUG mailist).
  7. To circumvent the LaTeX base warning: Float too big for page... for a Figure/Table that still fits the page, use
    the minipage environment with plain-TeX \vss to make LaTeX ignorant of extra height:
    \begin{figure}[p]
    \begin{minipage}[t][\textheight]{\textwidth}
    \centering \vspace{-1em} % some tweaking
    \includegraphics{...}
    \vspace{-0.5em} \caption{...} \label{fig:...}
    \vss % hides extra height
    \end{minipage}
    \end{figure}

    and do not forget that \label always go inside or straight after the \caption.
    See more on comp.text.tex.
  8. To prevent floats (Figures and Tables) from "floating away" too far from the desired place, or to have
    a footnote postponed until the next page, use the \usepackage{afterpage} package, providing a
    command \afterpage{ \do_something_after_this_page_ends }. For example,
    to force the queueing floats to be placed as soon as this page ends (without breaking it), put
    \afterpage{\clearpage}

    or, if you need to have a footnote to a Figure/Table that wrongly appears at the previous page, use
    \begin{figure}
    ...
    \caption{Blah-blah-blah \protect\footnotemark .}
    \end{figure}
    \afterpage{ \footnotetext{Some clarification.} }

    Note that this method is NOT very robust, particularly if you try to use the command inside the floats.
    Here is the package documentation and some more info on managing the floats.
  9. To avoid an extra space after a full stop, like in Latin 'etc.', 'e.g.', 'ca.', 'cf.', ...,
    put a backslash just after the full stop:
    ... e.g.\ we can avoid here an extra space.

    See more white space info.
  10. \textstyle command in the display mode switches fonts and spacing
    to be a more compact, e.g.
    \textsyle\sum e^{\textstyle a/b}

    The other LaTeX maths styles are \displaystyle, \scriptstyle and \scriptscriptstyle.
  11. See this wiki-guide for advanced Table Formatting.
[top]