Linux Commands Examples

A great documentation place for Linux commands

latex

structured text formatting and typesetting


see also : pdflatex - pdftex - tex

Synopsis

latex [first-line]


add an example, a script, a trick and tips

: email address (won't be displayed)
: name

Step 2

Thanks for this example ! - It will be moderated and published shortly.

Feel free to post other examples
Oops ! There is a tiny cockup. A damn 404 cockup. Please contact the loosy team who maintains and develops this wonderful site by clicking in the mighty feedback button on the side of the page. Say what happened. Thanks!

examples

1
source

Converting Open Office (odt) files to Latex

OpenOffice used to have a LaTeX export functionality, which was later removed, I guess. Nevertheless, there is a LaTeX writer:

sudo apt-get install openoffice.org-writer2latex writer2latex

Or, if your distribution uses LibreOffice, use libreoffice-writer2latex instead of the above.

Just confirm all messages with y. After installing, you can use it with w2l

w2l your-document.odt

which will create a .tex file with the same name. The formatting is pretty basic, but I think it gets the job done.

If you wish to edit it in Lyx after that, just concatenate the commands, something like that:

w2l your-document.odt && /usr/bin/env lyx your-document.tex &

I tested the conversion on Ubuntu 11.04 with the default LibreOffice installation

0
source
            
latex exjobb
0
source
            
latex *.tex
latex *.tex
dvips *.dvi
0
source

Unicode characters in bibtex

Bibtex is not really unicode aware. In order to use extended characters, you need to use the standard Tex replacements.

You might however want to use biblatex for a better management of bibliographic styles; and maybe have a look at biber, which aims to become a unicode aware Bibtex replacement.

0
source

Linux program to create a timeline diagram?

Than newer versions of Gnuplot are capable of handling timeline scales and can create annotations as well. It is originally a scientific plotting program, and can generate output in many formats including .png and .eps, so you can embed the results easily in LaTeX (it has a dedicated LaTeX output, which I am not familiar with). It has a quiet good and thorough documentation, plenty of settings and you can execute scripts in batch mode. You can even create a gnuplot script with a sheabang (#!) syntax.

0
source

updating TeX on linux

Debian still ships TeXLive 2009, which is now pretty quickly getting pretty ancient. As far as I know, there is no package (neither official nor unofficial) of TeXLive 2010. You have pretty much three options:

  1. You can install your own version of TeXLive 2010 in the /usr/local/ tree. Download it from tug, and follow the Unix installation instruction on that page. That will give you a complete current version of TeXLive. You will then be able to use tlmgr to keep your installation up to date. If you choose that path, make sure that the path to the new binaries is in your $PATH, and also in the roots $PATH, in order for maintainance binaries such as texhash and tlmgr to work.

  2. You can keep your current TeXLive, and just install the new versions of the packages you need in your local texmf tree. The local texmf tree on Debian based distributions is in /usr/local/share/texmf. If you don't have that directory, create it (as root, you will need to use sudo), download the packages from CTAN, and install them in there. You will need to run texhash as root to refresh TeX's file database, otherwise TeX will not find the new packages. The actual installation procedure will differ from package to package. If you can find a "tds compliant" zip file, you can just unzip it in /usr/local/share/texmf, run texhash as root and you will be done. If not, your best bet is to follow instruction in the README file that came with the package, or look at the package documentation if it contains some installation instructions.

  3. If you are the only one using TeX on that computer, you can also install the packages in your personal texmf tree, which on Debian is, I believe, in ~/texmf. The procedure for installing is pretty much the same as when installing in the local texmf tree, except that you don't have to be the root, and you don't have to run texhash after installation.

If you post the list of individual packages, someone may be able to give you more details.

0
source

How to cancel LaTeX compiling in Terminal?

Ctrl-D will do the trick.

However, use -file-line-error -halt-on-error on the command line. Or learn how to edit LaTeX from the compiler if you wanted to be hard core.

0
source

Automated printouts from a wireless printer

By no means is this the cleanest way of doing things. This is a general idea of what you could quickly hack together to achieve what you want to do.

Set up your printer

First and foremost, you want to get your printer working. CUPS does support wireless printers, so with a bit of luck and the right drivers you will be able to set that up. Refer to your server's distribution wiki / help pages for more information.

Get the data

You then want to get your data in plaintext. Google will help you find scripts that will do most the generic of the tasks that you need:

For other specific needs, you'll have to write them on your own:

  • TODOs depend on what mechanism you already use to keep track of that
  • Google Analytics. Unfortunately not accessible via command line browsers and I don't know anything about the Google Analytics API. I can only think of very ugly and unreliable ways of doing this so you will have to do some searching.

Hack your scripts together

We now have a bunch of scripts that work, but we need to put all that data together. For most of my hackjobs I go with Python. Not only is it easy to pick up and use, you can even "embed" other scripts into it a python file and grab their input:

from os import popen

script='''ps aux; echo; free -h'''

output=popen(script).read()

Not the best idea, but this way you don't have to re-write complex functions that are already available to you.

Formatting

HTML is easy to learn and prettify. Google to the rescue again: Python and HTML. Join the data we have with HTML, add a few lines of CSS to define what your page will look like (fonts, colors, layouts etc) and have python write all this into a file.

Print your document

  1. Save your script on your server and test it out. Jump to Can I print html files from the command-line? to do some test printing.

  2. Add a cronjob that will run your script every morning at the desired time.

  3. Add coffee.

Paper is a precious resource; I would have my webserver serve this file and read it on my tablet, phone, or laptop.

0
source

Convert TeX fragments to PNG images

You can use (and I have used) mathTeX:

MathTeX, licensed under the gpl, is a cgi program that lets you easily embed LaTeX math in your own html pages, blogs, wikis, etc. It parses a LaTeX math expression and immediately emits the corresponding gif (or png) image, rather than the usual TeX dvi. So just place an html tag in your document wherever you want to see the corresponding LaTeX expression.

It can either be used as a CGI script on the server and linked directly from the <img> tag, or run on the command-line to generate standalone image files. From the homepage:

mathTeX is usually run by your web server as a cgi program, obtaining its input expression from the query-string of an html tag. But you can also run mathTeX from your Unix shell, supplying all input on the command line. For example, ./mathtex.cgi "x^2+y^2" –o equation1 renders an image of x^2+y^2 in file equation1.gif.

0
source

typesetting system

LaTeX is pretty much the most used tool for professional typesetting in Linux, even though it is complex. While it's not perfect, it is much better for that purpose than Office-type packages are.

However, Scribus might be useful as a desktop publishing tool.

0
source

TTF Fonts in Latex on LINUX

Try googling tex truetype - there's plenty of hits. The top one looks fairly promising

http://www.radamir.com/tex/ttf-tex.htm

although I've never done this myself.

0
source

Looking for tex to html converter

Here is a short list of LaTeX to HTML converters. One of the ones listed is tth which is in the Ubuntu repositories (man page).

0
source

How to deal with lots of brackets in a formula?

Their is a vim script called foldcol.vim but I can't say more.

Personnaly I will do :

"put every calculs on one line
:%s/(/\r(\r/g
:%s/)/\r)\r/g

"delete all empty lines
:g/^$/d
"set fold as () to collapse them with "za"
:set foldmethod=marker foldmarker=(,)

"indent all text:
gg=G

It should look like :

Result: (
         (
          6*(
            k2+k3
            )
         )
         *A123*k2*k3*(
           A12*A13*k2^2-2*A12*A13*k2*k3+A12*A13*k3^2-A123*k2^2
           )
         *(
.
.
.

After working on it, remove indent : go to first line and then press :

 gg<G............ "need to press dot to repeat
 500gJ "to put all on one line

0
source

Export transparent-background equations from Latex

I'm not aware of any way of doing this using LaTeX itself, though you could just ImageMagick on the result. He's a script.

#!/bin/bash
texfile="$1"
pdffile="${texfile%.tex}.pdf"
pngfile="${texfile%.pdf}.png"
pdflatex -interaction=batchmode "$texfile"
pdfcrop "$pdffile" "${pdffile%.pdf}-cropped.pdf"
pdftoppm -png -f 1 -l 1 "${pdffile%.pdf}-cropped.pdf" > "$pngfile" 
convert "$pngfile" -transparent white "${pngfile%.png}-transparent.png"

You could use regular latex rather than pdflatex in the first command with dvipng. If you want a higher resolution, add the appropriate option to pdftoppm (e.g., -r 300 for 300 dpi; the default is 150 dpi if I'm not mistaken).

If you wanted a vector graphic instead, you could try Inkscape or dvisvgm, but I don't have a lot of experience with those.

0
source

Installing LaTeX package

You have not initialized tlmgr. Try first

 tlmgr init-usertree

and then

 tlmgr install amsmath

If this does not work, it is not your fault, but you will have to be patient: see posts n.3 and 4 in this bug report, and you will have to wait for a fix. In my Debian unstable, I do not experience such a bug, and tlmgr works perfectly.

description

This manual page is not meant to be exhaustive. The complete documentation for this version of TeX can be found in the info file or manual Web2C: A TeX implementation.

The LaTeX language is described in the book LaTeX - A Document Preparation System. LaTeX is a TeX macro package, not a modification to the TeX source program, so all the capabilities described in tex(1) are present.

The LaTeX macros encourage writers to think about the content of their documents, rather than the form. The ideal, very difficult to realize, is to have no formatting commands (like ’’switch to italic’’ or ’’skip 2 picas’’) in the document at all; instead, everything is done by specific markup instructions: ’’emphasize’’, ’’start a section’’.

The primary source of documentation for LaTeX is the LaTeX manual referenced below, and the local guide in the file local-guide.tex or local.tex or some such.

elatex is the e-TeX extended mode version of LaTeX format.

lambda is the Omega version of the LaTeX format.

pdflatex is the pdfTeX version of the LaTeX format.

On some systems latex209 and slitex are available for compatibility with older versions of LaTeX. These should not be used for new texts.


see also

amslatex, amstex, pdflatex , pdftex , tex .

Leslie Lamport, LaTeX - A Document Preparation System, Addison-Wesley, 1985, ISBN 020115790X.

Frank Mittelbach, Michel Goossens, Johannes Braams, David Carlisle, and Chris Rowley, LaTeX Companion, Addison-Wesley, 2004, ISBN 0201362996 (2nd edition).

LaTeX Graphics Companion, available as part of a boxed set: The LaTeX Companions, Revised Boxed Set : A Complete Guide and Reference for Preparing, Illustrating, and Publishing Technical Documents (2nd Edition), by Frank Mittelbach, Michel Goossens, Sebastian Rahtz, Helmut Kopka, Patrick W. Daly (Addison-Wesley, 2004, ISBN 0321269446).

How can this site be more helpful to YOU ?


give  feedback