## How to export from LyX to LaTeX

All of this information is out there, but it took me more than a few hours to successfully manage this on my Mac, so here are the steps, using LyX and TeXShop.

1. Go to File->Export->LyX Archive
This generates a zipped tarball of your .lyx file and, crucially, all the other elements (such as graphics and bibliography) in a hierarchy of files.
2. Unroll the tar ball (i.e. tar -xvzf yourarchive.tar.gz) in a suitable place.
You now have all the files you need in a standalone hierarchy (best to place your tarball in its own directory before you do this as the subdirectories you create could go under your root directory etc)
3. Convert the LyX file to raw LaTeX.
At this point all you have a LyX archive and if you really need LaTeX you need to convert the LyX file. On a Mac the easiest way to do this is to point LyX.app at the .lyx file in your archive and open it, then run another export – this time to LaTeX (pdflatex). This will create a .tex file in your archive. (I messed this stage up in the original posting – thanks, as always to Paul Rubin for putting me on the straight and narrow here.)

4. Make sure your bibliography is in the right place.
Your bibliography needs to be in the same directory. So if your .tex file is in the bizarro directory, your bib file must be too. (I said before it should have the same name as your .tex file but that is not necessary.)
5. Open your .tex file in TeXShop.
You may need to do some editing, for instance if your .tex file refers to your bibliography  under some path, so for the example above you need to make your bibliography reference look like this:
\bibliography{bizarrothings} 

6. Run the following sequence of commands in TeXShop:
Typeset LaTeX
Typeset BibTeX
Typeset LaTeX
Typeset LaTeX

Hopefully you now have compiled a PDF file with all the correct references, which means if you package up your archive directory it will now contain the correct .tex file (it will also contain the PDF and .lyx file unless you delete them first).

Hope this is helpful – if I have missed anything, let me know in the comments.

## How to use textpath with Metapost

It took me more than a few hours to get this working and as the manual is not at all fully clear on what you need to do (or rather, it assumes more knowledge of LaTeX than I had), I thought it would be useful to set this out.

Textpath allows one to draw text on a path (i.e., not just on a straight line). Here’s an example I prepared earlier:

Decus et tutamen as the coins say.

But using it is not as simple as I hoped it would be and even the very fine The LATEX Graphics Companion does not cover it – this is despite textpath being in the standard free TeX distributions and the alternative they describe – TXP – requiring a manual install.

Here are the key steps you need to get it to work.

Firstly, you have to configure your metapost file as a full LaTeX file and not just a piece of Metapost.

So at the top:

input latexmp; setupLaTeXMP(preamblefile="mypreamble"); input textpath; filenametemplate "%j-%c.mps";

And then you need to create your LaTeX preamble – i.e. the file I have called “mypreamble.tex” here but you can call it anything.

Here is mine:

\documentclass{article} \usepackage[T1]{fontenc} \usepackage[osf]{mathpazo} \usepackage{textpathmp}

This is what constrains your file as LaTeX.

This also means you have to end your file with an end after the endfig of the Metapost.

If you get some of this wrong you may find that you get an output but the strings (labels) are messed up – it is quite sensitive.

Here’s the file that generated the above graphic:


input latexmp;
setupLaTeXMP(preamblefile="mypreamble");
input textpath;
filenametemplate "%j-%c.mps";
beginfig(1);
prologues:=3;

%some colours
color lightgrey;
lightgrey:=(4/5, 4/5, 4/5);
color midgrey;
midgrey:=(3/5, 3/5, 3/5);
color darkgrey;
darkgrey=(2/5, 2/5, 2/5);
color gloom;
gloom=(1/5, 1/5, 1/5);

color azure;
azure:=(12/13, 1, 1);
color baby;
baby:=(12/13, 24/25, 1);
color lavender;
lavender=(23/26, 23/26, 49/50);
color ultra;
ultra=(8/13, 23/26, 12/13);
color ukraine;
ukraine=(66/255, 173/255, 222/255);
color turquoise;
turquoise=(0, 191/255, 1);

path hardware, virtlayer, kernel, user;
path hardwareL, virtlayerL, kernelL, userL;

hardware = fullcircle scaled 100;
virtlayer = fullcircle scaled 150;
kernel = fullcircle scaled 250;
user = fullcircle scaled 350;

hardwareL := reverse fullcircle scaled 75 rotated 180;
virtlayerL := reverse fullcircle scaled 125 rotated 180;
kernelL := reverse fullcircle scaled 225 rotated 160;
userL := reverse fullcircle scaled 325 rotated 160;

fill virtlayer withcolor lavender;
draw user;
fill user withcolor midgrey;
draw kernel;
fill kernel withcolor lightgrey;
draw virtlayer;
fill virtlayer withcolor lavender;
draw hardware;
fill hardware withcolor white;
draw textpath("Virtualisation", virtlayerL, 0);
draw textpath("Hardware", hardwareL, 0);
draw textpath("Kernel", kernelL, 0);

label.urt(btex Hardware virtualisation etex, (-200,-200));

endfig;
end;



There are lots of tricks to get the text looking the right way – e.g., inside or outside the path, left to right and so on. But they are described in the manual and I will leave them to readers to work out – getting the output at all is the most fundamental task!

## A bug in LyX illustrated (update: it’s a feature)

Update: It’s not a bug, it’s a feature (of LaTeX, not LyX) – see the comments.

So here’s me seeking to use my fantastic art skills once more to illustrate the bare bones of an SMP (symmetrical multiple processor) machine in a slide.

But this is what it ends up looking like…

The text just won’t align with the graphic (both are in minipages inside a minipage).

But if I add just one character (not a space!) above the graphic – it works. Arrgh.

## How do I do this?

I am preparing a computer science slide presentation and (as I am sane) do not want to use Powerpoint.

So I have been using LyX and the Beamer class.

The slides look great. But how do I add notes?

If I add notes “by hand” e.g. \note{Here is a note} – I see nothing in the PDFs.

And if I use the LyX “Noteitem” I get something like this “Note: Here is a note” on screen, but again nothing in the PDFs.

What am I doing wrong? I have looked at the LyX wiki and it is not illuminating.

## Anyone got any thoughts on the LaTeX companion?

Should I shell out £23 for The Latex Companion to ensure I can most effectively write my documents and design my slides for university? I have The LATEX Graphics Companion and there is no doubt it is a good book, but the number of books I could buy increases exponentially the more I think about the work I need to do. So, anyone have any practical experience with the book’s usefulness to a computer science research student with a middling level of LaTeX experience, who is likely to use LyX for a lot of his work?

## LaTeX symbol for the cartesian product

Lots of people come here looking for this, so I might as well oblige.

In mathmode the code is \times.

Giving $\times$

In textmode try: \texttimes

## I bought a book

Now I just have to decide what I want to do with it! I had thought about a LaTeX based application, as both LaTeX and LyX are thinly supported on Android. But that looks very ambitious at the moment.

We’ll see.

## GNU source-highlight, another great toy and tool

How did I never discover this before – GNU source-highlight, which also has a Qt-based front end.

The one key tip I have if you are using it to generate LaTeX for use with LyX is to make sure you scrub the comment at the top of the output.

## The Germans are coming (possibly)

I have already pointed out how German language books dominate in LaTeX and now I have found another area where German-language books suggest that the Germans are well-ahead of English speakers in their use of FOSS.

I can find three books on kernel virtualisation (KVM) in German:

(Strangely, though, none of these seems to be presently available.) In English there is only a technical report for Fedora 12 –Fedora 12 Virtualization Guide – though, admittedly, it would appear to be in print!