LaTeX

I’m writing a paper now, and it’s been recommended that I do it in LaTeX as it will be especially useful for when I come to write up my thesis or any large project. Also the journal that I’m submitting to prefers this format.

Any recommendations for good OSX and XP software? I’d like to start with something that lets me see both the code and the final page with live updating in real time without having to go through manual compilation and viewing.

Right now I’m checking out TeXnicCenter (from ProTeXt via MiKTeX), WinShell, WinEdit, native WinTexMacs / Cygwin TeXmacs, BaKoMa Tex Word and LEd on XP and TeXShop, LaTeXiT, TeXmacs and Lyx on OSX.

It looks like LyX is the closest match, though I can’t edit the source and the WYSIWYG preview simultaneously (though in this Open Source project the feature has been requested – search for “Edit source mode”)

LyX Editing Example

BaKoMa Tex Word looks like what I want (though it’s ugly and Windows only), but it’s only a limited (7 pages & 31 days) demo and costs a minimum of €55 for the license:

BaKoMa TexWord Simultaneous Source and Preview editing

[EDIT: 16:57] OMG, the lab director just told me that she wrote her entire PhD Thesis using LaTeX on Vi!

Advertisements

26 thoughts on “LaTeX

  1. “I’d like to start with something that lets me see both the code and the final page with live updating in real time without having to go through manual compilation and viewing”.

    And you call yourself a programmer. For what it’s worth, I use TeXShop. Here are two essential additions for bibliographies:

    http://bibdesk.sourceforge.net/
    http://www.ctan.org/tex-archive/help/Catalogue/entries/biblatex.html

    I proudly report that my bibliography file currently has 3831 entries.

  2. Thanks for your comments, guys. You’re both far too hardcore for me!

    Choosing a bibliography management tool seems quite a lot simpler – perhaps because I have considerably lower expectations of what it should do.

    BibTex on OSX looks good, as does the cross-platform JabRef. Both natively support .bib files rather than requiring their own funky databases, which makes it easier to take my data from one platform to another.

  3. I’ve been experiencing some problems with LaTeX recently.

    To start with, Bibtexkey entries…

    So let me get this straight: if I change the key in my bibliography then /cite{} won’t work anymore unless I manually update it. Suddenly all of my old documents fail to compile anymore. WTF?! Hello? Can you say “Content Management”? Why the fuck do I have to deal with this manual shit. I shouldn’t have to care what the key is, just make it work.

    I’ve resorted to using really long keys that include tonnes of information to make sure they’re meaningful. Previously I was using JabRef which can automatically generate keys based on the other fields, but for some entries that don’t have an author for example, the default key is empty or meaningless: /cite{a} is not terribly useful when you have to edit your document later on. Now what was that supposed to be citing? It’s like using a meaningless variable name in a regular programming language, it’s just bad practice.

    Another problem that caught me out was that notes can’t have underscores in them?!

    e.g.,

    @ARTICLE{M.SienaRoboticsandSystemsLabUniversityofSienaBringingHapticstoSecondLifeforVisuallyImpairedPeople2008SienaItaly,
    author = {Maurizio de Pascale, Sara Mulatto, Domenico Prattichizzo},
    title = {Bringing Haptics to Second Life for Visually Impaired People},
    year = {2008},
    url = {http://sirslab.dii.unisi.it/public/paper/depascale2008sl.pdf},
    note = {Last accessed 9th April 2008.

    Accepted for pubblication to “EuroHaptics 2008″.

    Stupid TeX can’t handle underscores here so I have to use %5F instead

    See also:

    http://sirslab.dii.unisi.it/research/haptic/projects/second%5Flife%5Fhaptics,
    organization = {Siena Robotics and Systems Lab},
    institution = {University of Siena},
    location = {Siena, Italy},
    month = {February},
    keywords = {Second Life, Haptics, Blind Walk, Blind Vision.}
    }

  4. I don’t see what’s so bad about being forced to stick to a convention for the BibTeX keys. I use author surname and year, so for example lewis_1979a and lewis_1979b would be the keys for the first two papers by Lewis published in 1979. You can configure BibDesk to automatically do this by using the following format string: %a1_%Y%u0

  5. That’s a good point, Brad. I should have illustrated my example.

    You see the problem is I think I might be abusing BibTeX by including entries that don’t fit very well into the normal kind of bibliography. For instance, I include corporate websites as well as regular articles. There’s usually a meaningful Year field – the copyright notice, the current year, or if the main page on the site has a Creation date then that would be best – but it doesn’t make sense to populate the Author field. So I’d end up with just a year, and that’s not very meaningful so my key would have to include at least Author_Organisation_Year.

    Sadly I only have a desktop PC, so I do most of my work in JabRef, not BibDesk, though I think I can configure that to automatically set up the key field automatically based on the entry type.

    I guess this is what I’m moaning about really. Until I’ve worked out a reasonable automatic key pattern my /cite{}s are going to be volatile and I’ll have to manually update them until I settle on a pattern that works reasonably consistently.

    Guess I should just get on with it! I’ll post my custom entry types (games, etc) here with my auto-key patterns when I’m happy with the.

  6. Ok, so I’ve taken a look at some of my entries again and am now using the following patterns for my keys, demonstrated with examples:

    Default: [auth][year]
    Bartle1996

    Software: [auth][developer][year]
    FreedomScientific2007

    Videogame: [developer][organization][institution][year]
    IdSoftwareInc1996

    Website: [auth][organization][institution][year]
    MSDN2001

    It does mean I have to poke around a bit more in order to extract reasonable data. For instance, I had to read through the Release Notes to find a date,

    http://msdn2.microsoft.com/en-us/library/ms695673(VS.85).aspx

    The key is still not terribly meaningful as I’m sure there are hundreds of entries in MSDN that came out in 2001. Maybe it’s good enough like this, I just get the feeling that this is going to come back to bite me later on.

  7. BibDesk only supports one form of automatic key generation, whereas JabRef allows different formats for each entry type (videogame, website, article, etc). This limitation is annoying because it means that if I want to have consistent \cite{} keys then I have to use the single BibDesk format, which is very long, and modify my JabRef automatic formats to use the same structure:

    %a1%f{Developer}%f{Organization}%f{Institution}%Y%u0
    [auth][developer][organization][institution][year]

  8. Another annoying issue with using JabRef (Windows, OSX) and BibDesk (OSX) is file encoding.

    I’ve figured out that I have to configure the following:

    JabRef:
    File -> Database Properties -> Database Encoding -> UTF8
    Options -> Preferences -> General -> Default Encoding -> UTF8

    BibDesk:
    Preferences -> Files -> String Encoding -> Unicode (UTF-8)
    Unicode to TeX Conversion -> Convert accented characters to TeX when exporting or pasting BibTeX

    This allows me to use umlauts in both of the applications, though reading my .bib file as ASCII in any standard text editor now means that what I see in my apps as Gröhn appears as Gr√∂hn in plain text, which in TeX would be Gr{\”o}hn, and which gets automatically generated as Groehn in JabRef’s /cite{} keys, but as Grohn in BibDesk!

    Haven’t we as a software industry had enough time to properly support non-ASCII encodings and non-Latin alphabets?

    I’m staggered that academics have tolerated this for so long. Am I missing something or does everyone have to deal with these poor usability issues?

  9. More madness!

    While editing entries, BibDesk offers an Annote tab but JabRef has Review. So in order to have a field that I can use to store my own comments about the entry I have to manually add “Annote” to the Optional Fields for all entry types!

    That sucks.

    I am a programmer.
    I am lazy, hubristic and impatient.

  10. Error handling in TeXShop:

    When I typeset my document the console window spews out a lot of largely unintelligible messages, mostly warnings about unfound citation keys.

    I would copy and paste the output here but the stupid app won’t let me select text from it’s window!

    Here’s a picture of it anyway,

    https://garethrwhite.wordpress.com/files/2008/04/picture-1.png

    First of all I tried pressing “Goto Error” but nothing happened.

    So then I tried reading through the previous messages and came across some interesting words, “Haptics.tex”, the name of one of my source files.

    So I open that document and look for line 37 where the console warned about a bad citation. I figure the real error can’t be far away. The console window mentioned something about a badly formatted {quote} environment, which I see is fortunately only on the following line.

    Is this how you generally use TeXShop? Surely it should automatically open the appropriate file and put the cursor on the error. And what about syntax highlighting? That wouldn’t hurt.

    In usability terms this is a pretty ropey process.

    Unfortunately Texmacs is an X11 application so it feels uncomfortable to use on OSX. LyX is something else and can’t seem to import my TeX files (and doesn’t give any useful error messages as to why) so I’m kind of stuck.

    Seriously, are there any good LaTeX apps for this operating system?

    • $man lacheck

      LaCheck(1) LaCheck(1)

      NAME
      lacheck – A consistency checker for LaTeX documents.

      SYNOPSIS
      lacheck filename[.tex]

      DESCRIPTION
      LaCheck is a general purpose consistency checker for LaTeX documents. It reads a LaTeX document and displays warning messages, if it finds bad sequences.

  11. Hmm, how do I configure TeXShop to call BibTeX with an optional include directory for .bst files?

    I’d normally store my .bst in ~/Library/texmf/bibtex/bst/ which is fine and all, but I’d like to keep all my .bib, .bst and .tex files in one place on a removable Flash drive with this kind of directory structure,

    /TeX/bib/*.bib
    /TeX/bst/*.bst

    /UniversityOfSussex/projectX/*.tex
    /UniversityOfSussex/projectY/*.tex

    This works fine when I use TeXnicCenter on XP as it allows me to configure appropriate command line parameters for the binaries, but how do I do this in TeXShop?
    Normally .bst files are kept in,

    TeXShop standard files:
    /usr/local/texlive/2007/texmf-dist/bibtex/bst/base/*.bst

    TeXShop user styles files (seems to work fine with my custom style files):
    ~/Library/texmf/bibtex/bst/*.bst

    Similarly for ~/Library/texmf/bibtex/bib/*.bib

    Simply creating a symbolic link from ~/Library/texmf/bibtex to my Flash drive works perfectly for both .bib and .bst files. Thanks Unix!

    I don’t know what these are, and if I put style files here TeXShop doesn’t seem to find them:
    /sw/share/texmf-dist/bibtex/bst/base/*.bst
    /usr/local/texlive/texmf-local/bibtex/bst/local/

    Then iTeXMac has these:
    ~/Library/Application Support/iTeXMac2/Projects.put_aside/sw/share/texmf-dist/bibtex/bst/base/abbrv.texd/abbrv.bst

    Apparently

    texmf is for system-dependent material (pool files, config files)
    texmf-dist is for the public system-indepedent packages
    texmf-local is for local configuration and private changes
    texmf-var is a cache of files which are created automatically

    On Ubuntu

    /etc/texmf/texmf.cnf reads as follows:

    % The tree containing the runtime files closely related to the specific
    % program version used:
    % [GARETH] No document classes here
    TEXMFMAIN = /usr/share/texmf

    % The main distribution tree:
    % [GARETH] Some style files /usr/share/texmf-texlive/tex/latex/BLAH/BLAH.sty
    TEXMFDIST = /usr/share/texmf-texlive

    % A place for local additions to a “standard” texmf tree.
    % This tree is not used for local configuration maintained by
    % texconfig, it uses TEXMFCONFIG below.
    % [GARETH] Doesn’t exist by default
    % /usr/local/share/texmf/latex/acm_proc_article-sp/acm_proc_article-sp.cls
    TEXMFLOCAL = /usr/local/share/texmf

    % TEXMFSYSCONFIG, where texconfig-sys stores configuration data.
    % With teTeX-3.0 or later, this must be set.
    % For sharing this tree with $TEXMFMAIN:
    % TEXMFSYSCONFIG = $TEXMFMAIN
    % For using a separate tree:
    % TEXMFSYSCONFIG = /usr/share/texmf-config
    TEXMFSYSCONFIG = /etc/texmf

    % User texmf trees are allowed as follows.
    % This used to be HOMETEXMF.
    % [GARETH] TeX doesn’t seem to recognise $TEXMFHOME/tex/latex/styles/… even when I’ve run sudo texhash $TEXMFHOME
    TEXMFHOME = $HOME/texmf

    % BibTeX bibliographies and style files.
    BIBINPUTS = .;$TEXMF/bibtex/bib//
    BSTINPUTS = .;$TEXMF/bibtex/{bst,csf}//

    I find that I need to include my class files in either of these three directories,

    On OSX and Ubuntu:
    /usr/share/texmf-texlive/tex/latex/acm_proc_article-sp/acm_proc_article-sp.cls
    /usr/share/texmf/tex/latex/acm_proc_article-sp/acm_proc_article-sp.cls

    OSX only:
    /var/lib/texmf/tex/latex/acm_proc_article-sp/acm_proc_article-sp.cls

    So basically I should be able to link to my Flash drive thus,

    ln -s /media/16\ GB\ FLASH/LaTeX/bibtex ~/texmf/bibtex
    ln -s /media/16\ GB\ FLASH/LaTeX/styles ~/texmf/styles

    texhash only lists the following updates, but it doesn’t seem to matter as my .bib .bst and .cls files are being used correctly.

    gw43@HOLESTREET:~$ sudo texhash
    texhash: Updating /var/lib/texmf/ls-R-TEXMFMAIN…
    texhash: Updating /var/lib/texmf/ls-R-TEXLIVE…
    texhash: Updating /var/lib/texmf/ls-R…
    texhash: Done.

    I also use Kile, and to configure this I need to do:
    Settings -> Configure Kile -> LaTeX -> General -> Environment Variables ->
    BIBINPUTS
    BSTINPUTS

    export TEXINPUTS=”.:/path/to/texinputs//”; export LATEXINPUTS=$TEXINPUTS; export BIBINPUTS=”.:/path/to/bibinputs//”; export BSTINPUTS=”.:/path/to/bstinputs//”;

  12. Just spent a hell of a long time trying to get Lyx to use the ACM document class.

    Finally figured out a way to make it work, copy the following into these locations:

    /Applications/LyX.app/Contents/Resources/layouts/acm_proc_article-sp.layout
    /Applications/LyX.app/Contents/Resources/tex/acm_proc_article-sp.cls

    At the command line type ‘sudo texhash’
    Launch Lyx
    Select Lyx->Reconfigure
    Restart Lyx

    For normal TeX applications though, you’d need to put it in

    ~/Library/texmf/tex/latex/acm_proc_article-sp/acm_proc_article-sp.cls

    But I notice that TeXShop will also try to pick it up from anywhere in that hierarchy, such as

    ~/Library/texmf/tex/latex/lyx/acm_proc_article-sp.cls

    On Unix you need to do it like this:

    /usr/share/texmf/tex/latex/acm_proc_article-sp/acm_proc_article-sp.cls
    ~/.lyx/layouts/acm_proc_article-sp.layout

    sudo texhash
    Lyx
    Tools->Reconfigure
    Lyx

    I still don’t know how to get Lyx to produce output using this document class that is compatible with LaTeX though. I get lots of errors when I try to process the .tex file output from Lyx…

  13. BST Hacking

    I’ve just discovered that

    type$ “manual” =
    ‘author.organization.sort
    ‘author.sort
    if$

    is different to

    type$ “manual” =
    ‘author.organization.sort
    { ‘author.sort}
    if$

    I thought they both were saying

    If type is “manual”
    then push “author.organization.sort”
    else
    push “author.sort”

    Actually the second one pushes a temporary function literal that itself pushes the string literal “author.sort”. In order to actually execute the function we’d need to remove the leading apostrophe if we enclose it in curly brackets.

    So the real bug here was that I didn’t realise that { … } creates a temporary function and pushes a reference to it onto the stack.

    Doh!

    Here’s the documentation (from btxhak.pdf),

    Note that the built-in functions while$ and if$ require two function literals on the stack. You get them there either by immediately preceding the name of a function by a single quote, or, if you don’t feel like de ning a new function with the FUNCTION command, by simply giving its de nition (that is, giving what would be the second argument to the FUNCTION command, including the surrounding braces). For example the following function fragment appends the character `a’ if the string variable named label is nonnull:
    . . .
    label “” =
    ‘skip$
    { label “a” * ‘label := }
    if$
    . . .

  14. Don’t use the underscore character _ in your .bib files!

    I just had a reference who’s title included an underscore in it. After running BibTeX then LaTeX I get a misleading error in distant section of the document:

    Missing $ inserted. \newblock games_

    FWIW the original reference was “games_access” so there’s a bit of a clue in the error message, but this citation was referenced much much earlier in the document. Bah.

    So to summarise, BibTeX / LaTeX are so lame you have to remember these obscures little gotchas to everyday problems.

    Fucking rubbish.

    • Can’t emphasise this enough…

      There must be no underscore _ characters anywhere in your bibliography.

      This will cause TeX to die.
      Furthermore, due to the poor error handling of TeX, it will be difficult to identify the cause of the error.
      I have a BibTeX entry with the following fields

      @article{Anonymous:2008p100,
      Journal = {Develop},
      Month = {Jun},
      Pages = {1–84},
      Title = {Develop 84 – 2008_06},
      Year = {2008}}

      This will not cause a problem on the first call of LaTeX. Nor will it cause a problem when running BibTeX. It’ll only manifest when you call LaTeX again, with an error like this,

      Overfull \hbox (89.27814pt too wide) in paragraph at lines 3963–3964
      []\OT1/cmr/m/n/10 “[]\OT1/cmtt/m/n/10 12 Things To Do In Second Life That Aren
      ‘t Embarrassing If Your Priest Or Rabbi Finds Out\OT1/cmr/m/n/10 ”
      (./Footer.tex (./test.bbl [88]
      ! Missing $ inserted.

      $
      l.82 Develop 86 – 2008_
      08.
      ?

  15. Pingback: Bibliographic Software « Gareth R. White

  16. More crazy BibTeX hacking,

    acm_proc_article-sp.cls

    \gdef\additionalauthors#1{\addauthors={#1}}

    \gdef\numberofauthors#1{\global\aucount=#1
    \ifnum\aucount>3\global\originalaucount=\aucount \global\aucount=3\fi %g} % 3 OK – Gerry March 2007
    \global\auskipcount=\aucount\global\advance\auskipcount by 1
    \global\multiply\auskipcount by 2
    \global\multiply\auskip by \auskipcount
    \global\advance\auwidth by -\auskip
    \global\divide\auwidth by \aucount}

    This is interesting as it starts by closing a tabular element.

    Now my question is, how to get 5 authors listed either all on the same line, or 3 on the first and 2 on the second? Right now I the fourth and fifth go over the right hand side of the page, reporting error,

    Overfull \hbox (229.99994pt too wide) in paragraph at lines 87–87

    There’s some comments that give a hint,

    % make aubox hsize/number of authors up to 3, less gutter
    % then showbox gutter showbox gutter showbox — GKMT Aug 99
    \newbox\@acmtitlebox
    \def\@maketitle{\newpage
    \null
    \setbox\@acmtitlebox\vbox{%
    \baselineskip 20pt
    \vskip 2em % Vertical space above title.
    \begin{center}
    {\ttlfnt \@title\par} % Title set in 18pt Helvetica (Arial) bold size.
    \vskip 1.5em % Vertical space after title.
    %This should be the subtitle.
    {\subttlfnt \the\subtitletext\par}\vskip 1.25em%\fi
    {\baselineskip 16pt\aufnt % each author set in \12 pt Arial, in a
    \lineskip .5em % tabular environment
    \begin{tabular}[t]{c}\@author
    \end{tabular}\par}
    \vskip 1.5em % Vertical space after author.
    \end{center}}
    \dimen0=\ht\@acmtitlebox
    \advance\dimen0 by -12.75pc\relax % Increased space for title box — KBT
    \unvbox\@acmtitlebox
    \ifdim\dimen0<0.0pt\relax\vskip-\dimen0\fi}

    It looks like the answer to my question is to use code a bit like this in my article.tex, which actually displays 3 on the first line and 2 on the second.

    \numberofauthors{5}
    \author{
    \alignauthor
    Gareth R. White \and Dave Harley \and \and Lesley Axelrod
    \end{tabular}
    \\ % [GARETH] Push the next two onto the following line
    \begin{tabular}[t]{p{\textwidth}}
    \alignauthor
    Geraldine Fitzpatrick \and Graham McAllister \\ \\ % [GARETH] The first \\ doesn't appear to do anything, the second is to include a new line

    In order to get all affiliation data on the same line I have to use something like this in my article.tex file immediately after the preceding author section

    % [GARETH] Trick to get contact details to display correctly
    \end{tabular}
    \begin{tabular}[t]{p{\textwidth}}
    \centering
    %123456789012345678901234567890123456789012345678901234567890123456789012345678901\\
    \affaddr{Interact Lab, Department of Informatics, University of Sussex, Brighton, UK, BN1 9QH}\\
    \affaddr{http://www.informatics.sussex.ac.uk/interact/}\\
    \email{\{g.white,d.a.harley,l.axelrod,g.a.fitzpatrick,g.mcallister\}@sussex.ac.uk}
    }

  17. This has always been a problem for me. I’ve just found the following buried inside Help -> TeXShop Help Panel -> Advanced Help -> Removing AUX Files:

    When documents are typeset, auxiliary files are created with extensions .aux, .log, .bbl, etc. Occasionally these files can become corrupt and lead to unexplained typesetting errors. TeXShop has a menu command “Trash AUX Files” which will remove all such files so typesetting can proceed. There is a similarly named button on the Console window. If either of these items is activated, TeXShop will move to the trash all files in the current source directory with the same name as the source file and extension aux, blg, brf, ccs, ent, fff, glo, idx, idv, ilg, ind, ioa, lg, log, lot, mte, mlf, out, pdfsync, toc, ttt, wrm, xref, 4ct, 4tc, or fdb_latexmk.

    Additional extensions can be added to this list. To add “dvi” to the list, activate the Terminal and type

    defaults write TeXShop OtherTrashExtensions -array-add “dvi”
    To remove all additions and return to the original default list, tppe

    defaults write TeXShop OtherTrashExtensions -array
    Sometimes more extensive cleanup is needed. For example, if a book is controlled by main.tex, and chapters are in subfolders accessed with commands like \include{chapter1/chapter1}, then typesetting the book will create main.aux, main.pdfsync, and main.log in the main folder, and chapter1.aux in the chapter1 folder.

    The required extensive cleanup can be done by holding down the option key while choosing “Trash AUX Files.” In this case:

    “%!TEX root” and Root File information will be used to find the root document and its folder
    All files with appropriate extensions in this folder or any subfolder will be moved to the trash, regardless of the name of the file
    There is a way to make this behavior the default behavior for “Trash AUX Files” even if the option key is not down:

    defaults write TeXShop AggressiveTrashAUX YES

  18. Another gripe with TeXShop, it’s search facility is “excremental”. i.e., it’s not incremental.

    This shouldn’t be such a big job to fix – save the original cursor position, then when the search field is modified, invoke the search with the current search term from the original cursor position.

    There’s probably some kind of OSX callback for when an interface element (like the search box) is modified, so this can just invoke (a modified version of) the search method that’s normally called when you click the Next button.

    A couple of possibilities,

    http://michael-mccracken.net/2009/09/an-update-on-the-incremental-search-plug/

    http://www.tug.org/pipermail/macostex-archives/2006-April/021872.html

    Though it’s not clear whether this will work in SnowLeopard,

    http://stackoverflow.com/questions/1338978/inputmanager-plug-ins-in-snow-leopard-os-x-10-6

    http://hints.macworld.com/article.php?story=20071026235641392

    http://hints.macworld.com/article.php?story=20090903043702715

  19. This is pretty bad behaviour,

    http://anorien.csc.warwick.ac.uk/mirrors/CTAN/macros/latex/contrib/import/import.sty

    % Depending on on how your \TeX\ system is configured, if a file with the
    % same name as the import file exists in the current directory or in the
    % TEXINPUTS path, that other file will be read in preference to one in the
    % import directory.

    Consider the following files,

    ./import.tex:

    \documentclass[10pt]{minimal}
    \usepackage{import}
    \begin{document}
    \subimport{}{doc}
    \subimport{child}{child}
    \end{document}

    ./doc.tex:

    Top level doc.

    ./child/child.tex:

    Child doc.
    \subimport{}{doc}

    ./child/doc.tex

    Child level doc.

    Typesetting these will produce the following:


    Top level doc. Child doc. Top level doc.

    Instead of what you’d expect,


    Top level doc. Child doc. Child level doc.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s