How do I use TrueType fonts with LaTeX - latex

I need to use a font family in my LaTeX documents, that is available as 18 .TTF (TrueTypeFont) files.
Where do I have to copy the files in my MiKTeX 2.8 installation?
How Do I make the fonts available for LaTeX?
I usually use pdfLaTeX. I read in Truetype-Fonts in LaTeX that TTF fonts are available without creating all the .TFM files. What is necessary for this case?
Can I install the fonts in the local-texfm directory? I would like to isolate the system installation and my manually added stuff. Probably it would be easier to copy this font family on another installation.

The easiest way would be to use XeLaTeX, for which you would just install the fonts to your system. A basic template would look like this (from https://web.archive.org/web/20111115151939/http://theotex.blogspot.com/2008/04/what-is-xetex-basic-template_15.html) :
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
\documentclass[10pt]{memoir}
\usepackage{xltxtra,fontspec,xunicode}
\defaultfontfeatures{Scale=MatchLowercase}
\setromanfont[Numbers=Uppercase]{Hoefler Text}
\setmonofont[Scale=0.90,Ligatures=NoCommon]{Courier}
\title{Your Title}
\author{Your Name}
\date{}
\begin{document}
\maketitle
\chapter{Title}
\section{Section Title}
Your text
\subsection{Subsection Title}
Your Text
\end{document}

If you want to stick to LaTeX, you can generally try these steps:
Create the TeX font metrics (tfm), the font description (fd) and the font mapping (map).
Using ttf2tfm to generate .vpl, then vptovf to create .tfm.
Put the files (ttf, tfm, fd, map) into the proper directories in the local texmf tree.
Update the TeX filename database.
Using texhash
Register the mapping.
Using updmap-sys
It seems rather straightforward, but there are many traps regarding the font description and mapping, as well as the naming scheme for the output files.
There are a lot of scripts and howtos which didn't work for me. So I wrote this tool to help me use ttf fonts with LaTeX: http://devnotcorp.wordpress.com/2011/06/10/use-truetype-font-with-pdflatex/.

Although it's many years later I thought of adding that if one uses LuaLaTeX, you don't need to do anything apart from using the LuaLaTex package fontspec and then in the preamble of in the document \setmainfont{ComicSansMS}.

Use ttf2tfm and ttf2pk programs

try the following: http://www.radamir.com/tex/ttf-tex.htm. I tried it several YEARS ago; i found some bugs but I can't remember them anymore. I think it had something to do with wrong files being used with another program. The author had SWITCHED file extensions due to confusion because of the number of files being generated. I notified the author about it but I don't know if he had corrected it.

Related

sphinx customization of latexpdf output?

Just curious if anyone knows how to customize the sphinx output when using the latexpdf target? I've seen lots of custom stuff for html output, but cant seem to find any example of custom pdf output.
Specifically, I'd be interested in customizing the title page, headers, footers, and possibly adding a few pages of front matter before the contents.
Has anyone seen any examples of this kind of customization, or do people pretty much just use the "stock" sphinx output when generating pdfs? Thanks!
Yes i think better or clearer documentation for latex styling would be nice and
some examples.
Here is a question on the sphinx mailing list, which is about about using packages.
sphinx has its own latex documentclass in a file called sphinxmanual.cls or
sphinxhowto.cls, if i remember correctly its a report documentclass that is used as base.
then there is 2 style files, which are the packages, it is those files contents
that are called on when you write \usepackage{mylatexstilefile}
Question about using latex packages
http://groups.google.com/group/sphinx-dev/browse_thread/thread/890dab5e53fff004
Here is my conf.py.
preamb_old = ur'''
%\documentclass{memoir}
\makeatletter
\fancypagestyle{normal}{
\fancyhf{}
\fancyfoot[LE,RO]{{\py#HeaderFamily\thepage}}
\fancyfoot[LO]{{\py#HeaderFamily\nouppercase{\rightmark}}}
\fancyfoot[RE]{{\py#HeaderFamily\nouppercase{\leftmark}}}
\fancyhead[LE,RO]{{\py#HeaderFamily \#title}} % here's the change
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
}
\makeatother
%\color {blue}
%\normalcolor {dark blue}
\pagecolor [RGB]{255, 247, 226}
\definecolor{VerbatimColor}{rgb}{0.95,0.85,0.65}
\definecolor{VerbatimBorderColor}{rgb}{0.5,0.95,0.1}
'''
f = open('graph/static/latexstyling.tex', 'r+')
PREAMBLE = f.read();
latex_elements = {
'papersize':'a4paper',
'pointsize':'11pt',
'classoptions': ',openany',
'babel': '\\usepackage[english]{babel}',
'preamble': PREAMBLE
}
i don't use preamble_old anymore, but it is an example of changes directly in
conf.py, to your latex preamble.
Check out latex_elements and latex_additional_files in the sphinx docs as
a starting point.

LaTeX: Cite, but don't reference

I'm producing a set of documents in LaTeX, and I would like to provide a single, global bibliography page for the whole set. This is because each document is page-limited: I don't want to take up space with references at the bottom of each one.
This means in each case, I would like to cite in the text, but not produce a reference at the end. I am using bibtex/natbib to handle the referencing.
Simplest example:
\documentclass[]{article}
\bibliographystyle{/usr/share/texmf/bibtex/bst/natbib/plainnat.bst}
\usepackage{natbib}
\begin{document}
In \citet*{MEF2010} I described the method.
\bibliography{bibliography.bib}
\end{document}
How can I do this? Essentially I just want it to cite correctly:
In Bloggs, Blagg and Blog (2010) I described the method.
But not add a references section at the end. Any ideas?
Thanks,
David
Instead of using \bibliography{bibliography.bib} you can try \nobibliography{bibliography.bib}.
You still need to enter the path so it can make the cross-references.
It happens due to missing packages. If you want to resolve the problem then enable the automatic installation packet. After that,First, you run the BibTeX file and generate the Pdf file (instead of pdfLatex file) and then pdfLatex to Pdf

LaTeX lstlisting not highlighting keywords when basic style is ttfamily

I'm working on a LaTeX document and using lstlisting to display my Java source code. My setup looks like this:
\lstset{
basicstyle=\ttfamily,
keywordstyle=\bfseries,
language=Java,
frame=single,
aboveskip=11pt,
belowskip=11pt,
breaklines=true,
breakatwhitespace=false,
showspaces=false,
showstringspaces=false
}
The keywords are not highlighted bold when using ttfamily, but if I use small or don't specify the basic style, they're highlighted fine.
What am I missing?
The default font in LaTeX, Computer Modern, does not provide a bold version of the teletype family. You can install this as the bold-extra package; see this FAQ entry for details.
Another option is to swap which fonts you're using for bold as described here: http://www.macfreek.nl/mindmaster/LaTeX_Bold_Typewriter_Font
Just putting this line at the top of my document worked for me on a pretty standard Ubuntu build:
\DeclareFontShape{OT1}{cmtt}{bx}{n}{<5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>cmttb10}{}
There is an alternative approach (a bit simplee IMHO) here using a Courier font instead of the default Computer Modern:
% Using Courier font
\renewcommand{\ttdefault}{pcr}
\begin{lstlisting}[basicstyle=\ttfamily\bfseries]
y:=2
\end{lstlisting}
All credits goes of cause to Marco Daniel!

LaTeX help with href

I am trying to create a hyperlink using LaTeX. When I use the command pdflatex to compile the file, I get an error.
The relevant lines of the document are:
\documentclass[12pt]{article}
\usepackage{hyperref}
\begin{document}
...
\href{http://www.cs.utah.edu/dept/old/texinfo/as/gprof_toc.html}{gprof}
pdflatex created a file called missfont.log, which contains this:
mktextfm pzdr
What am I doing wrong?
Do you have the pzdr font installed? If you're on Debian or Ubuntu, try installing the texlive-fonts-recommended package.
Does the hyperref package purport to make hyperlinks to arbitrary web pages? I thought it was just for intra-document links (which it does automatically). I would do
\usepackage{url}
and
\url{http://foo.com}
to format a URL in your document.
ADDED: Thanks Will, I didn't know that about href. But if you're creating a document that's mainly targeting paper as the intended medium, I think the url package for formatting URLs is the way to go. But if you think the href package subsumes the url package, I'd love to be set straight on that.

Detecting output device in LaTeX

Is there a way, in a LaTeX style/class file, to detect which output device is being used (or at least which capabilities it has)? The reason is, I'm writing a class file in which I want to use some Postscript-specific packages (e.g. pstricks) if Postscript is available, but if I just write
\RequirePackage{pstricks}
then of course bad things happen if I'm compiling the document with pdflatex. So ideally I'm looking for something I can use like
\if#postscriptokay\RequirePackage{pstricks}\fi
It seems like this must be possible because I know packages like pgf can change their behavior to use appropriate graphics commands based on the output device, but I've done some Google searches and checked in my LaTeX book and haven't found a way.
\usepackage{ifpdf}
\ifpdf
% nothing
\else
\RequirePackage{pstricks}
\fi
You can detect pdfTeX like this (this is what ifpdf.sty does):
\makeatletter
\ifx\pdfoutput\#undefined
no pdfTeX
\else\ifnum\pdfoutput<1
pdfTeX is outputting a .dvi file
\else
pdfTeX is outputting a .pdf file
\fi\fi
graphicx.sty, hyperref.sty and pgf.sty have their own autodetection mechanisms built in. They load a different driver file (like pdftex.def and hpdftex.def) based on the autodetection and the package option. If you load any of these in your .tex file, try to get the information which driver they loaded. The relevant driver files are:
/usr/share/texmf/tex/generic/pgf/systemlayer/pgfsys-*.def
/usr/share/texmf-texlive/tex/latex/hyperref/hpdftex.def
/usr/share/texmf-texlive/tex/latex/graphics/*.def
/usr/share/texmf-texlive/tex/latex/pdftex-def/pdftex.def
The name of the driver for pgf.sty and graphicx.sty is stored in the macro \Gin#driver. You can inspect this macro after loading any of these packages.
Have a look at packages pstool and auto-pst-pdf. They are here to help use pstricks and friends with pdfLaTeX.
If you are using the KOMA-Script package (which I can really recommend, unless you need to use a different style of course) you already have a macro for this: \ifpdfoutput{pdf output}{dvi output} is defined in that package. If not, use the ifpdf package as has already been mentioned.

Resources