Posts Tagged ‘tex’

Install ETH Fonts for LaTeX on Mac OS X

Thursday, February 7th, 2013

This turned out to be quite difficult.

I installed TexLive using macports.

If you download the ETH letter LaTeX templates and try to compile you will get an error like:


! I can't find file `letr8t'.
<*> ...:=ljfour; mag:=1; nonstopmode; input letr8t
                                                  
Please type another input file name
! Emergency stop.
<*> ...:=ljfour; mag:=1; nonstopmode; input letr8t
                                                  
Transcript written on mfput.log.
grep: letr8t.log: No such file or directory
mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input letr8t' failed to make letr8t.tfm.
kpathsea: Appending font creation commands to missfont.log.
! Font \xiiiv=letr8t at 8.5pt not loadable: Metric (TFM) file not found.
 
                   \relax 
l.112 \newfont{\xiiiv}{letr8t at 8.5pt}

This is complaining that you don’t have the ETH fonts installed. These are a pain to install.

Unzip into your macports texmf folder:


sudo unzip ETHLfnts.zip -d /opt/local/share/texmf/

Create a hash for the new files:


sudo texhash

If you try to compile brief2.tex now you will get an error:


kpathsea: Running mktexpk --mfmode / --bdpi 600 --mag 1+0/600 --dpi 600 letb8r
mktexpk: don't know how to create bitmap font for letb8r.
mktexpk: perhaps letb8r is missing from the map file.
kpathsea: Appending font creation commands to missfont.log.
(see the transcript file for additional information)
!pdfTeX error: pdflatex (file letb8r): Font letb8r at 600 not found
 ==> Fatal error occurred, no output PDF file produced!

Open and append:


p +let.map

Now compiling should give you the error:


gsftopk: fatal: map file `let.map' not found.
mktexpk: don't know how to create bitmap font for letb8r.
mktexpk: perhaps letb8r is missing from the map file.
kpathsea: Appending font creation commands to missfont.log.
(see the transcript file for additional information)
!pdfTeX error: pdflatex (file letb8r): Font letb8r at 600 not found
 ==> Fatal error occurred, no output PDF file produced!

Create the file /opt/local/etc/texmf/ethfonts.cfg and add the line:


Map let.map

Update maps listing:


sudo updmap-sys

Now if you should get an error like:


ERROR:  The following map file(s) couldn't be found:
	let.map (in /opt/local/var/db/texmf/web2c/updmap.cfg)

If you try to compile brief2.tex you’ll get an error like:


gsftopk: fatal: map file `let.map' not found.
mktexpk: don't know how to create bitmap font for letb8r.
mktexpk: perhaps letb8r is missing from the map file.
kpathsea: Appending font creation commands to missfont.log.
(see the transcript file for additional information)
!pdfTeX error: pdflatex (file letb8r): Font letb8r at 600 not found
 ==> Fatal error occurred, no output PDF file produced!

So, copy let.map to your local texlive directory:


mkdir -p ~/.texlive2012/texmf-var/fonts/map/dvips/updmap/
cp /opt/local/share/texmf/maps/let.map ~/.texlive2012/texmf-var/fonts/map/dvips/updmap/

Update maps listing:


sudo updmap-sys

Now you should be able to successfully build:


pdflatex brief2

Citing CGAL or other software using acmsiggraph.bst bibtex style

Monday, January 14th, 2013

CGAL suggests that you use the following bibtex record:


@misc{cgal,
  title = "\textsc{Cgal}, {C}omputational {G}eometry {A}lgorithms {L}ibrary",
  note  = "http://www.cgal.org"
}

But the acmsiggraph.bst style creates citations that look like:


[cga ]

To fix this I use a slightly different bibtex record:


@misc{cgal,
  key = {CGAL},
  title = "\textsc{Cgal}, {C}omputational {G}eometry {A}lgorithms {L}ibrary",
  note  = "http://www.cgal.org"
}

And changed the lines in acmsiggraph.bst that look like:


FUNCTION {author.key.label}
{ author empty$
    { key empty$
        { cite$ #1 #3 substring$ }
        { key #3 text.prefix$ }
      if$
    }
    { author format.lab.names }
  if$
}

to


FUNCTION {author.key.label}
{ author empty$
    { key empty$
        { cite$ #1 #3 substring$ }
        % Alec: use full key
        { key }
      if$
    }
    { author format.lab.names }
  if$
}

and the lines that look like:


  year empty$
  {
    "\protect\citename{" swap$ * " }" *
    "" * 'label :=
  }

to


  year empty$
  {
    % Alec: rm space after name if no year
    "\protect\citename{" swap$ * "}" *
    "" * 'label :=
  }

Now my citation looks like:


[CGAL]

Nabla (∇) in matlab plot title

Thursday, September 6th, 2012

I tried:


title('\nabla');

Which produces no errors or warnings on the terminal, but the title in the plot on my mac is just a little question mark in a black box: �
You can do a little better by switching to the latex interpreter, which unfortunately uses that smelly latex font


title('$\nabla$','interpreter','latex');

Show \textwidth and \linewidth values in latex

Wednesday, April 11th, 2012

Here’s a snippet you can paste into your latex document to reveal the values of \textwidth and \linewidth printed into your document. First include this in your header:


\usepackage{layouts}

Then in your content someplace:


textwidth: \printinunitsof{in}\prntlen{\textwidth}

linewidth: \printinunitsof{in}\prntlen{\linewidth}

Vim sometimes only partially syntax-highlighting for .tex files

Thursday, May 12th, 2011

Editting .tex files with vim I noticed that sometimes I got full syntax highlighting, but other times only certain keywords were markes and the colors were a bit different. Turns out this was because vim was occasionally recognizing files (based on keywords) as plaintex rather than tex. You can see what filetype vim thinks you have open by issuing:


:set ft

For a bit I was fixing this on a case-by-case basis, if vim’s highlighting was wrong I would issue:


:set ft=tex

and that would fix it for at least the current file and session.

The real permanent fix was to add the following to my ~/.vimrc file:


let g:tex_flavor = "latex"

Now all my .tex files are recognized as tex and not plaintex.

Blacked-out text in LaTeX

Sunday, November 28th, 2010

Here’s a small command you can add to your LaTeX document’s header that will let you “blackout” text like a censored Watergate era document.


\newlength{\blackoutwidth}
\newcommand{\blackout}[1]
{%necessary comment
  \settowidth{\blackoutwidth}{#1}%necessary comment
  \rule[-0.3em]{\blackoutwidth}{1.125em}%necessary comment
}

The command is easy to use and automatically adjusts to the word or phrase that should be blacked out, as long as it’s not longer than a line. Here’s an example of \blackout in use:
blackout example latex

The above can be compiled from the following LaTeX document:


\documentclass[letterpaper,11pt]{article}
\newlength{\blackoutwidth}
\newcommand{\blackout}[1]
{%necessary comment
  \settowidth{\blackoutwidth}{#1}%necessary comment
  \rule[-0.3em]{\blackoutwidth}{1.125em}%necessary comment
}
\begin{document}
\noindent
{\tiny Deep Throat's true identity is \blackout{Mark Felt}. \\
Deep Throat's true identity is Mark Felt.}\\
{\small Deep Throat's true identity is \blackout{Mark Felt}. \\
Deep Throat's true identity is Mark Felt.}\\
Deep Throat's true identity is \blackout{Mark Felt}. \\
Deep Throat's true identity is Mark Felt. \\
{\bf Deep Throat's true identity is \blackout{Mark Felt}. \\
Deep Throat's true identity is Mark Felt.}\\
\emph{ Deep Throat's true identity is \blackout{Mark Felt}. \\
Deep Throat's true identity is Mark Felt.}\\
{\Large Deep Throat's true identity is \blackout{Mark Felt}. \\
Deep Throat's true identity is Mark Felt.}\\
{\huge Deep Throat's true identity is \blackout{Mark Felt}. \\
Deep Throat's true identity is Mark Felt.}\\
\end{document}

LaTeX “for any” symbol

Sunday, October 18th, 2009

for any or for all symbol

The upside-down capital A (∀) as in “for all” or “for any” element(s) in a set, can be typeset in LaTeX using the TeX macro in math mode:


\forall

Typeset (La)TeX and open pdf with one line command from vi/vim (or Emacs, etc.)

Tuesday, September 29th, 2009

I habitually use vim to edit files, particularly latex code. Ashamedly I only recently realized you could make shell calls without leaving vim just by typing

:![command]

When I’m editing a TeX file I am constantly typesetting my document to a pdf then opening the pdf. Here’s a one-line vi(m) specific bash command to typeset your current document to a pdf then open that pdf using your default pdf viewer.


:!if pdflatex "%"; then open "`echo "%" | sed "s/\(\.[^\.]*\)$/.pdf/g"`"; fi

If you do not have or want to use the open command just replace it with some other viewer like ghostview or xpdf.

Note: Here’s the multi-line version of the exact same thing if you want to save it in a callable bash script:


!/bin/bash
if pdflatex $1; then
  open `echo $1 | sed "s/\(\.[^\.]*\)$/.pdf/g"`
fi

If you save the above in an executable file called openpdflatex then you could still call it from vi or vim with


:!openpdflatex %

Update: Occasionally I include .eps figures so I need to first make a .dvi with the latex command then use dvipdf to convert to pdf. Here’s how I do it in one line from vi(m):


:!if latex %; then if dvipdf `echo % | sed "s/\(\.[^\.]*\)$/.dvi/g"`; then open `echo % | sed "s/\(\.[^\.]*\)$/.pdf/g"`; fi; fi

Update: All these if statements can be condensed using the && bash operator. Making these much easier to just type out whenever, wherever you need them. Like this:


:!pdflatex % && open `echo % | sed -e "s/tex$/pdf/"`