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

Sunday, December 18, 2011

Fedora 16 Install Notes

Notes on using the pre-upgrade method to go from Fedora 14 to 16 (yes, it's risky to skip a version). The reason for my upgrade is that Fedora 14 is now at end-of-life, I'd like to get FEniCS working, and some of the new spins look pretty cool.

One of the things I had to manually fix after reboot was the TexLive development repo (only 60% complete, estimated for Fedora 17). I had this activated to get the IJ4UQ styles to work.
yum remove texlive-release
rpm -i http://jnovy.fedorapeople.org/texlive/packages.f16/texlive-release.noarch.rpm
Manually remove some old conflicting packages (some from Fedora 12, yikes! I'm a lazy sys-admin).
List the repositories to make sure everything is pointing at the correct release version.
yum repolist
Sync things up.
yum distro-sync
I got this error: grubby fatal error: unable to find a suitable template. According to the forum I did,
mv /boot/grub/grub.conf /boot/grub/grub.conf.old
and then,
yum reinstall kernel
yum clean all && yum install texlive

The other problem I ran in to was with the hwloc package. I had to downgrade it to the 1.2.1 version, the 1.3 version seems to be missing the shared library needed by mpich and scotch.

Saturday, August 13, 2011

Latex for Blogger: Pandoc

The previous post showed some new math rendering tools for supporting Latex for Blogger. That still relied on htlatex (in the tex4ht package) for converting Latex into HTML. I just found another tool called Pandoc that converts between lots of different markup languages. Here’s the first paragraph from the manpage.

Pandoc is a Haskell library for converting from one markup format to another, and a command-line tool that uses this library. It can read markdown and (subsets of) Textile, reStructuredText, HTML, and LaTeX; and it can write plain text, markdown, reStructuredText, HTML, LaTeX, ConTeXt, RTF, DocBook XML, OpenDocument XML, ODT, GNU Texinfo, Medi‐ aWiki markup, EPUB, Textile, groff man pages, Emacs Org-Mode, and Slidy or S5 HTML slide shows.

Sounds promising. So, this post is written in Latex, and then I converted it to HTML with this command:

  [jstults@grafton pandoc]$ pandoc -f latex -t html -o pandoc.html pandoc.tex 

Here’s some test equations:
f(x) = x2

$\frac{\partial U}{\partial t} = \nabla U $

Φ  = ϕ - ∫ t0tf(τ) dτ

Saturday, July 30, 2011

Latex for Blogger

A couple of years ago, I posted that I was using htlatex to do math-heavy posts. This worked in a pinch, the equations are all nicely rendered as *.png’s and they have all the normal Latex auto-numbering and cross-referencing. This only works for posts though, no equation support in comments. I learned about MathJax, which is a much better option than non-scaling pngs for math, and it supports equations in comments. All it requires is adding a script to the blogger template file.

  <script src=’http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML’ type=’text/javascript’> 
  </script>

Then run htlatex with the mathml option.

  [jstults@grafton]$ htlatex foo.tex ”xhtml,mathml”

This turns foo.tex into foo.html, which has the equations in MathML markup. MathJax renders the MathML so everything looks pretty.

MathJax also renders any Latex it finds on the page (including in comments!). The normal single dollar sign for inline math does not work, since this would cause trouble if people were trying to discuss money. Here's what does work though:

  % inline math in comments use: 
  $$ x + y = z $$ 
  % equations in comments use: 
  \[ x + y = z \
  % or  (for numbered equations): 
  \begin{equation} x + y = z \end{equation}
 inline in comments:  
 \ ( x + y = z  \)
A couple numbered equations in the post \begin{equation} \frac{\partial x}{\partial t} = A x \end{equation} foo \begin{equation}\frac{\partial y}{\partial t} = g(y) + f \end{equation}

Sunday, April 12, 2009

Maxima Latex Listings

The listings package is a really nice way to include typeset source-code listings in Latex documents. I wanted to include an appendix in one of my documents to show the Maxima calculations I used to arrive at some results shown in the paper. Unfortunately Maxima is not one of the (many, many) built-in languages recognized by the package. I tried using C, because the comments in Maxima are like C comments, but it doesn't handle single quotes (used to get noun forms like 'diff()) well. So, how to include listings of Maxima code in Latex?

It turns out to be really easy to define your own language in the preamble of the document.

\lstdefinelanguage{Maxima}{
keywords={addrow,addcol,zeromatrix,ident,augcoefmatrix,ratsubst,diff,ev,tex,%
with_stdout,nouns,express,depends,load,submatrix,div,grad,curl,%
rootscontract,solve,part,assume,sqrt,integrate,abs,inf,exp},
sensitive=true,
comment=[n][\itshape]{/*}{*/}
}

All this definition does is italicize comments and bold face the keywords, which is sufficient to make the code more readable and pleasant looking. Here's an example screenshot of the results:

Wednesday, December 3, 2008

Latex for Blogging

I've been using htlatex command that comes with the tex4ht package to generate images of nicely typeset equations for use in my blog posts. There are several alternatives for turning latex into html. This article has a decent overview of a few of the methods you might use if you want to have a single tex source file for publishing on the web and on paper. I'm not that serious about my content management. I don't mind a little manual cutting and pasting.

I tried using latex2html, but that is really more suited for processing a large structured document and turning it into a large, structured set of web-pages. All I need is equations, so htlatex is sufficient. If I have a list of equations in 'example.tex', then the command:

$ htlatex example.tex

Produces png image files of all the equations right there in that directory, it even includes the equation labels and alternative text in the generated html, which latex2html does not do. I've noticed that the images generated for a 12pt document look a little better (because they are bigger) when you insert them into a post.

If you're a Fedora user, getting this useful little tool is as easy as

$ yum -y install tetex-tex4ht

Monday, November 10, 2008

SCons for Latex

Latex is really great for publishing papers with nicely typeset equations and graphics. It automates all of the little formatting stuff and lets you spend time developing the content of your paper rather than wasting effort fiddling with format. I've been using GNU Make for years to process my Latex sources into dvi's and pdf's, but it's always been pretty painful and clumsy (mostly because I'm not a Make guru).

The makefiles for a Latex document can get pretty ugly and complicated especially if your document depends on various data or graphics files. SCons is a new and improved build-tool that implements its configuration files as Python scripts, the file is called SConstruct now instead of Makefile. The great thing from my point of view is that it has built-in support for Latex. Making a pdf from my Latex source file is simple:

env = Environment()
env.PDF('main.tex')

The PDF builder is smart enough to know it needs to run pdflatex and then based on the output possibly run bibtex and then pdflatex again to track down undefined references (or not). All in two lines of Python.

The really neat thing is how easy it is to extend the built-in build environments.

env = Environment()
plot_bld = Builder(action = 'gnuplot < $SOURCE > $TARGET,
suffix = '.png'
src_suffix = '.gp')
env.Append(BUILDERS = {'Plot' : plot_bld})
env.PDF('main.tex')

Now my SCons can automatically update my png graphics files based on gnuplot commands in any files ending with .gp.

Practical Development Environments has a nice little write-up in Chapter 5 about SCons.