Showing posts with label latex. Show all posts
Showing posts with label latex. Show all posts

Friday, 1 October 2010

Stupid papersize stupid stupid

After finally getting to the stage where my thesis would compile on a different computer (see last post to install the extra .sty files), I then discover my page headers have disappeared on my pdf output. It turns out that this is due to the default ps2pdf setting being US letter paper, rather than the A4 size that the rest of my document is on. The answer (for the moment, anyway) is this:
ps2pdf -sPAPERSIZE=a4 thesis.ps
I'm forced to go a-latexin' followed by dvipsin' then ps2pdf because of some bounding box issues with my images with pdflatex that I can't be bothered to solve.
That will serve me right for having a typo in my thesis.

Thursday, 30 September 2010

Installing a latex .sty file

I've never managed to successfully do this until now. Here's the deal:
1) download & unzip the package from CTAN
2) run latex on the .ins file so that it creates a .sty file
3) find out what your computer thinks your TDS tree should be:
kpsewhich -var-value TEXMFLOCAL
(mine says "/usr/local/share/texmf")
4) create the tree /usr/local/share/texmf/tex/latex/ if it isn't already there (where is the name of your sty file)
5) paste in your .sty file
6) run mktexlsr /usr/local/share/texmf/
7) profit.

Monday, 16 August 2010

Including pdf files into latex

Further to my earlier post today, this post is the story of how I managed to get my research papers into my thesis as appendices. The earlier post tells a fascinating tale of how I sorted the page counters out and forced some blank pages. I then compiled up to pdf (via ps2pdf, to include my eps diagrams). To insert my other pdf pages I wrote a new latex file to stitch stuff together using pdfpages. Sadly this makes my hyperlinks go away, but nevermind. The object here is to be able to have a file which can be printed and bound by people who don't care to re-arrange pages for me. Behold:

\documentclass[a4paper,portrait]{article}
\usepackage{pdfpages}

\begin{document}

\includepdf[pages={1-32}]{thesis.pdf}
\includepdf[pages={33-34}, landscape, turn=false]{thesis.pdf} % some landscape pages
\includepdf[pages={35-202}]{thesis.pdf}
\includepdf[pages={1-5,{},{},{}}, landscape, nup=1x2, turn=false]{Appendices/specs.pdf}
\includepdf[pages={203-204}]{thesis.pdf}
\includepdf[pages={1-4}]{Appendices/prl.pdf}
\includepdf[pages={205-206}]{thesis.pdf}
\includepdf[pages={1-4}]{Appendices/pra.pdf}
\includepdf[pages={207-220}]{thesis.pdf}

\end{document}

Chunks of my thesis are included (I guess you can spot them), including some landscape pages as a special case. The "turn = false" means that any pdf viewers still display them as portrait. This was important to me, as I want to be able to check they're not going to print upside down! The last two appendices are four pages each and on American letter ("freedom") paper, but that's okay: they'll be scaled for A4. The "specs.pdf" file is 5 pages long and I have included it as 2-up printing on landscape pages which show as portrait in the viewer. Since I needed ensure that they occupy 4 sides of A4 in total, I included 3 blank pages denoted by the empty braces {}. So, the first two-and-a-half sides of A4 have the 5 pages of specs.pdf, and then there are one-and-a-half blank sides following.

I compile with pdflatex.

LaTeX: coloured text and blank page fun.

I want to insert some research papers into my thesis. These are in separate pdf files which I don't yet know how I will insert. (pdfpages isn't my friend because I'm banned from using pdflatex due to having eps graphics which I can't be bothered to convert.)

I'll figure out that bit in a minute, but right now I want to force a blank page (with a header and footer) which will be printed on the reverse of an appendix section page. This has to come before the place where I will insert the pdf pages. Actually, latex adds this page automatically at the moment, because it wants my "Appendix" section pages to be on the right-hand sides of my document. The issue is that if I then start to add to my page counter, the reverse-side blank page has the wrong page number for where it will be printed!

Here's my work-around. Each introductory page for an appendix goes like this:

\chapter{An included paper}
Following is a copy of an amazing paper from our research group.
\newpage
\mbox{}

The mbox ensures the new page actually happens. Then, before the next \include{} in the master file, I add four pages (the research paper length!) to my counter.

\addtocounter{page}{4}

So far, so awesome. Now I'll fight to include the papers in the file. I'm thinking psutils...

OH! I forgot to tell you about coloured text! Before I found the mbox doo-dah I was going to just write "cheese" in white on the blank page. I'd do the following in my preamble:

\usepackage{color}
\definecolor{orange}{rgb}{1,0.5,0}

and then on my "blank" page, I'd do:

\newpage
\textcolor{orange}{cheese}

Ok, that's orange, but you get the picture. You can define white.

Monday, 7 June 2010

Non-coloured hyperrefs in latex

So, I love to leap around my thesis like superman using the "hyperref" package. However, I do not like increased printing costs by having pretty pink references on every page (our printer selects the cheaper b/w printing intelligently). I was colouring my links black using this clunky bit of code:
\hypersetup{
colorlinks,%
citecolor=black,%
filecolor=black,%
linkcolor=black,%
urlcolor=black
}
...but this resulted in the printer choosing to mix colours to achieve black text on pages with a hyperlink! Argh! It looked stupid, it was stupid! Hopefully this more elegant bit of code might fix whatever oddity is occuring:
\hypersetup{pdfborder={0 0 0},colorlinks = false}
The pdf certainly looks no different... fingers crossed for printing time.

Friday, 4 June 2010

Sidewaystable prints upside down

I have two consecutive landscape tables in my thesis using the "sidewaystable" package. The package rotates them so that the top of the table is closest to the spine of the book, however this manifests itself in the pdf as the page headers and footers appearing to the right of one landscape page, and to the left of the next. When I print double sided, one page has a header which is upside down. My preamble is thusly:

\documentclass[a4paper,11pt,twoside]{book}
\usepackage{rotating}

... the solution was to choose:

\usepackage[figuresright]{rotating}

So that the figures are always in one direction. Now my headers are always to the right of the landscape page. Hopefully this will now force them to be the right-way-up! If they both print upside down, I suppose I must choose [figuresleft] instead. I've no idea if this is just a symptom of my particular combination of pdf reader and printer, but hey-ho.

Thanks to the Szwer for solving this one for me.

Wednesday, 24 March 2010

Breaking URLs in BibTeX

Here's a work-around for a sticky problem when citing URLs in LaTeX documents.

My problem manifested itself in ugly URLs in my bibliography which did not break over multiple lines, causing underfull hboxes all over the shop: the line of text preceding the URLs had 5 words spread horridly across the page.

I tried various work-arounds found via google but the one that eventually solved my problem was found here in "BibTeX tips and FAQ" by M. Shell and D. Hoadley.

My preamble contains the following:
\usepackage{url}
\usepackage[ps2pdf, pagebackref]{hyperref}

And I cite all my URLs in BibTeX like this:
\url{http://morecakelessfish.blogspot.com/}

I like to compile into pdf by using dvi2ps then ps2pdf otherwise I seem to have some issues with offset bounding boxes in my pyxplot .eps graphics. Despite calling the url package in my references (see example above), my URLs still weren't breaking. Apparently this is a problem when going via dvi after including the hyperref package. The problem was solved by including breakurl.sty AFTER the hyperref package in my preamble thusly:

\usepackage{url}
\usepackage[ps2pdf, pagebackref]{hyperref}
\usepackage{breakurl}

Jobs a good'un.

Friday, 16 May 2008

Fixing dvips

We have a lovely shiney (the case really is!) new computer named Lewis. (This is after Lewis Hamilton, because he is so fast).

Anyway, it was super fast to build and amazingly the whole kit works, even the processor fan started so our new core2duo didn't melt. Mandriva 2008.1 installed quicker than it takes our old laptops to boot up. Now I have to iron out all the little problems getting things to work. (Like why Firefox is thinking every word in the english language that I'm typing is spelt wrong!!!).

First up, I can't seem to convert dvi to ps in Kile. Actually, it doesn't work on the command line either- it says:
dvips: ! Couldn't find header file cm-super-t1.enc.
Note that an absolute path or a relative path with .. are denied in -R2 mode.

R2 is some sort of secure mode. I am using texlive. Part of the problem is that dvips is correct- I really didn't have this file. I installed the following package:

texlive-texmf-cmsuper

But dvips still couldn't see it where it was hiding (which was in /usr/share/texmf-texlive/fonts/enc/dvips/cm-super). It seems that dvips uses the same search-y doo-dah as TeX, so all I needed to do was update the lists by running

texhash

as a superuser. It's happy now.

Friday, 8 February 2008

Installing a .sty file!

At last, I succeed in one thing!
I needed bbding.sty, so I downloaded the whole zip from CTAN. It included the .ins and .dtx files. I stuck it in a local temporary place and followed the instructions on this handy page.
I ran latex on the .ins file and then on the .dtx file. I then moved the whole folder and everything in it to my local texmf tree:
/usr/local/share/texmf/tex/latex/
into a folder of the same name, ie. bbding. Next, as a superuser I ran:
texhash
and we all lived happily ever after.

Wednesday, 19 December 2007

Another post, in which I continue to destroy/re-build my LaTeX installation with my hopeless fumblings.

So, for some reason, I downloaded the TeTeX documentation and stumbled across kpathsea.pdf in the TeTeX documentation menu in Kile. It seems that this is involved in searching for various files needed for LaTeX. For some reason, I tried to run mktexlsr instead of texhash. I probably wasn't managing to find the place where the script was saved, but something seemed to run. But then there was no ls-R file in /usr/local/share/texmf anymore. When I tried to compile any LaTeX code, the text came out ok, but any mathematical symbols, etc. were totally missing. On closer inspection, it was secretly crying that kpathsea couldn't find mf.base. So I managed to stop it finding metafont, or something crazy. I tried to compile the RevTeX sample which came out as a hopeless jumble of lines and which decided randomly to print itself on the group printer.
The shame! The despair!
I have since restored /usr/share/texmf/web2c/texmf.cnf to its former glory and run texhash and I now at least have a working LaTeX again.
Again, I make the changes to texmf.cnf that I made before, and this time run texhash. Boo hoo hoo. Computer says no:

This is dvips(k) 5.95b Copyright 2005 Radical Eye Software (www.radicaleye.com)
' TeX output 2007.12.19:1045' -> atomicstructure.ps
kpathsea: Running mktexpk --mfmode ljfour --bdpi 600 --mag 1+57/600 --dpi 657 cmmi10
kpathsea: Running mktexfmt mf.base
fmtutil: format `mf' not available.
mktexpk: Mismatched mode ljfour and resolution 600; ignoring mode.
mktexpk: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1+57/600; nonstopmode; input cmmi10
This is METAFONT, Version 2.71828 (Web2C 7.5.5)
kpathsea: Running mktexfmt mf.base
fmtutil: format `mf' not available.
I can't find the base file `mf.base'!
grep: cmmi10.log: No such file or directory
mktexpk: `mf-nowin -progname=mf \mode:=ljfour; mag:=1+57/600; nonstopmode; input cmmi10' failed to make cmmi10.657pk.
kpathsea: Appending font creation commands to missfont.log.
dvips: Font cmmi10 not found, characters will be left blank.
kpathsea: Running mktexpk --mfmode ljfour --bdpi 600 --mag 1+0/600 --dpi 600 cmmi8
kpathsea: Running mktexfmt mf.base
fmtutil: format `mf' not available.
mktexpk: Mismatched mode ljfour and resolution 600; ignoring mode.
mktexpk: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1+0/600; nonstopmode; input cmmi8
This is METAFONT, Version 2.71828 (Web2C 7.5.5)
kpathsea: Running mktexfmt mf.base
fmtutil: format `mf' not available.
I can't find the base file `mf.base'!
grep: cmmi8.log: No such file or directory
mktexpk: `mf-nowin -progname=mf \mode:=ljfour; mag:=1+0/600; nonstopmode; input cmmi8' failed to make cmmi8.600pk.
dvips: Font cmmi8 not found, characters will be left blank.
. [1]

I think I must be creating the wrong files. A more intelligent approach is needed, ie. engage brain.

Monday, 17 December 2007

Installing LaTeX packages

This post is going to change a lot as I try this new feat. I'm writing as I go, and this may not even work. Worse, I might break my current LaTeX distribution. Wish me luck.

I'm using several very helpful pages. One is the readme file for the package I'm installing, and the other is here.

I download the package I want: it happens to be REVTeX4. It's saved as revtex4.tar.gz somewhere temporary. My path $TEXMFLOCAL happens to correspond to /usr/local/share/texmf. This is where all my updates will be stored- in a nice local file, so I can find them again. In this path, I created some handy directories...
mkdir /usr/local/share/texmf/tex
mkdir /usr/local/share/texmf/tex/latex

I changed directories here:
cd /usr/local/share/texmf/tex/latex
next moved the tar file into this location...
cp /temporarylocation/revtex4.tar.gz .
the full-stop is not a typo. I un-tarred it like so:
tar -zxvf revtex4.tar.gz
I had to be acting as a superuser, of course, to wield such fantastic powers. I now have a lovely directory named revtex4. The readme suggests I put the *.bst files in $TEXMFLOCAL/bibtex/bst/revtex4, so I do the following:
cd /usr/local/share/texmf/
mkdir bibtex
mkdir bibtex/bst
mkdir bibtex/bst/revtex4
cd bibtext/bst/revtex4
cp /usr/local/share/texmf/tex/latex/revtex4/*.bst .
I think I shall also delete them from their current home in /tex/latex/revtex4 for good measure. It is now time to instruct my TeX system where to find it all. I altered a cunning file:
kwrite /usr/share/texmf/web2c/texmf.cnf
From here on, I (almost) quote verbatim from this page.

I had already defined a directory for local material, and stuck everything there. This was /usr/local/share/texmf.

If your configuration file has a line that says something like:
TEXMFLOCAL=$SELFAUTOPARENT/share/texmf
...then you are fine; leave it alone. Some older distributions instead have a line like
TEXMFLOCAL=/usr/local/share/texmf
...commented out (it starts with a percent sign). If yours is commented out, then below it put the non-commented $SELFAUTOPARENT line (and date the change in the file; sometimes that's helpful).
Mine had the "older distribution" option, but it wasn't commented out, so I left it as it was.

Turn on searching of that local directory. A bit further down I found this line
TEXMF = {$HOMETEXMF,!!$TEXMFLOCAL,!!$TEXMFMAIN}
I commented this line out by prefixing a percent sign to the line. Below it I added a new line:
TEXMF={$HOMETEXMF,$TEXMFLOCAL,!!$TEXMFMAIN}
...in which I've deleted the twin exclamation points. The twin exclamation points tell the system that if it does not find a file in the main tree's ls-R database then it should not go on to search the disk. That's OK because your main tree will never change since you will put new things into the local tree. So the rehashing done [later] will be up to date forever. (Older versions have a TEXMF=!!$TEXMFMAIN line which you can comment out and replace with what's above.)


The page also offers wisdom on what I'm actually doing. The re-hashing I do at the end.

Your TeX system can precompute the position of [certain] files so that, instead of scanning the directory tree on your physical disk, your system finds where a file is in a database file called 'ls-R', which lists that directory tree. Then your TeX goes straight to that spot in the directory structure on the disk to get the file's contents. (The software libraries that do this work are called `kpath'.) Point One: If you make any changes to a precomputed portion of your setup then you must rebuild (or `rehash') the database of files, or your changes won't be found.

I continue:

Insure that searching of that local directory is done on disk. For certain kinds of files (such as .vf files), if the system finds a filename database in the directory tree then it will look for that file only in the database -- it will not go on to search the disk (whether there are twin exclamation points or not). Thus, for those files, forgetting to rehash results in your system saying that it cannot find files that you know are in the right place. To avoid that puzzlement, we will omit creation of that database for the local tree... I found this line
TEXMFDBS=$TEXMF;$VARTEXFONTS
...commented it out with a percent sign, and added this just below it:
TEXMFDBS=$TEXMFMAIN;$VARTEXFONTS
The version with TEXMF would have caused TEXMFDBS to expand to include the local tree, but now with TEXMFMAIN it will only include the distribution's tree.

And now for the hashing of the database:

Run the command to remake the ls-R filename database. I first checked that there was no ls-R file in the local directory /usr/local/share/texmf and then I did this.
texhash
The system responded by telling me that it had made /usr/share/texmf/ls-R (and also a /var/lib/texmf/ls-R file that has to do with user-created fonts that I will not discuss). The main point is that the system did not make /usr/local/share/texmf/ls-R. Consequently, searches of the local material will be made on disk.

Et voila. Thank you, oh great author of handy page (and sorry for stealing your text- I reproduce it here in case it disappears, or I can't find it again!)

LATER: Ok, this appears to have broken my LaTeX as predicted. I'm having problems with finding Metafont. Will sort this out and post in a later post about it, if I can fix it.