Wednesday, April 14, 2010

Making video from images

I made a nice model in blender of a toroidal microresonator, and ended up making an animation of it. The first time round I exported it as a sequence of .jpg files (yeah yeah, should have been .png I know), so while blender is making the video file I tried to make a video from the sequence.

use ffmpeg:

ffmpeg -f image2 -i img%02d.jpg -r 16 tor.avi
Is what I ended up using. I don't know what -f image2 means, but
-r 16 means 16 frames per second
-i img%02d.jpg means that the .jpg files with name starting img followed with 2 digits buffered by zeros will be used.

There are more fancy shit you can do, but at this point I couldn't be bothered to check it out.

here are some websites:
http://www.catswhocode.com/blog/19-ffmpeg-commands-for-all-need


 

Wednesday, March 10, 2010

LaTeX Thesis Template for Macquarie University

Alexei Gilchrist customised a very good LaTeX thesis template for Macquarie University, Faculty of Science students. It can be found on his blog here http://ectropy.info/2009/03/latex-thesis-templates. I have made some minor changes to the template:

1) The "hyperref" macros package is now included in the class file and can be activated by using the option "foronline" in the document class options ( \documentclass[foronline]{mqthesis} ). Citations and references will then be hyperlinked within the document as will links to external sites and emails. The thesis index it also hyperlinked to the chapter and sections. All of this really only works if you are using pdflatex to make your pdf document. If you want to make a pdf copy for black and white printing just leave out "foronline".

2) A \pdfinfo section is also included in the thesis.tex file. This includes meta data into the pdf document, such as title, author and keywords.

For more info on the changes and how the template works, see the readme file and the documentation within the thesis.tex file and the mqthesis.cls (if you have to make changes) class file.

I think the LaTeX thesis template is pretty much perfect for Macquarie University students in the Faculty of Sciences as it is now. To use this thesis template for your faculty just get the right Macquarie University logo for your faculty. I tried to find these to include them, but gave up eventually. They were easy to find once, but now they are gone. WTF MQ?

Adapting the mqthesis LaTeX template to your university:

1) Get your university logo and slap it in the UNIlogos folder and rename it mqlogo.
2) Open the mqthesis.cls file in a text/tex editor.
   a) Search for all "Macquarie University" and change to your uni's name.
   b) If you want to change the bibliography style search for "\bibliographystyle" and change it to something you like.
3) Fiddle with the margin sizes if your uni is particular about these, other wise just leave as is.
4) Save your changes.  

Yep, and that's about it, you can change the way the chapter headings look by playing with  "\usepackage[grey,times]{quotchap}", enjoy and happy thesising.

The template can be downloaded from here:  http://members.iinet.net.au/~johannelna/mqthesis_v23.zip

Monday, January 25, 2010

LaTeX in your figures with XFig (shudders)

So in a recent paper I've put together I put beautiful axis labels and misc. LaTeX stuff on my EPS figs. by using the \put commmand. in the "picture" environment. It goes something like this:
\begin{figure}[tbp]
\begin{center}
\setlength{\unitlength}{1cm}
\begin{picture}(8,7)
\put(-0.8,0.5){\includegraphics[width=8.4\unitlength]{figure1.eps}}
\put(0,0){$\ket{1}$}   % this makes a |1> and puts it at (0,0) ie. bottom left
\end{picture}
\end{center}
\end{figure}
It is very handy and super cool. Much to my dismay however the journal did not agree with me:

"PLEASE NOTE,..., we ask that you adhere to the following guidelines with regard to your figure files:
     One or more of the figure files you have provided are not complete,... . Please be advised that each figure file should contain the entire contents of the figure. Use of commands in your manuscript source file to include axis labeling or other such content to your figures is problematic for us.  These commands should be removed from your manuscript TeX file and complete files for each of the figures should be submitted." 

Fantastic. So here then is how you put the LaTeX in your figures and keep PRA happy:
First we need an archaic program Xfig. It is a "new" version, but it is an X program (runs under X windows), and feels old and weird. Under linux install the transfig package as well. Under other OSes follow the instructions. WARNING, under Mac OSX 10.4.11 I couldn't save my Xfig figures. Not cool. I ended up doing in Linux.
Using: xfig -specialtext -latexfonts -startlatexFont default 
at the command line will open Xfig ready to go for using LaTeX commands. Otherwise make sure that for the text boxes the "text flags" are set to "special". This is done on the bottom of the screen. $...$ puts you in mathmode.

Once you have all your LaTeX goodies put in, export the figure as combined ps/latex. This gives you 2 files, a figure1.pstex, and a figure1.pstex_t. Now create a LaTeX driver file. It is going to compile the LaTeX part and the picture part into one thing:
\documentclass{article}
\usepackage{epsfig}
\usepackage{color} 
\setlength{\textwidth}{100cm}
\setlength{\textheight}{100cm}
\begin{document}
\pagestyle{empty}
\input{figure1.pstex_t}
\end{document}
Compile it (not using pdflatex) ie make a .dvi file. Lets say you called your LaTeX document converter.tex. Then from the terminal run:
dvips -E converter.dvi -o figure1.eps
Now you have a nice .eps figure with all your LaTeX goodies.

NB!! You have to make the figure in Xfig the size you want it in your document. If you scale your funky new .eps in your LaTeX  document your labels are going to scale as well. So make the picture the size you want, and use the font size you would like to have in your document.   <--This is why I would just stick with /put for labels when doing a thesis, or whenever you can get away with it.


 Further info:
http://epb.lbl.gov/xfig/latex_and_xfig.html
http://graphics.stanford.edu/infrastructure/howto/xfig_latex.html
Usermanual
I hope this helps.

Tuesday, January 19, 2010

Aquamacs for your LaTeX needs in OS X.

I recently decided that I wanted an improvement over TeXShop. One of the best solutions I came across was Aquamacs, an emacs version specifically configured for LaTeX and OS X. It has very good syntax highlighting and even puts your section headings in bigger bold typeface (after a while you notice how this is REALLY cool). You can also run a preview, which shows the output of figs and equations in your document, a wysiwyg type preview.  Getting it setup took longer than I would have liked, so here is how to do it correctly, without wasting time. Download the Aquamacs .dmg  here http://aquamacs.org/download.shtml

Skim:
Skim is a very good pdf viewer, and works great with aquamacs, enabling forwards and backwards searches. That is, you can jump from a point in your LaTeX document to the corresponding point in the pdf document, and also do the reverse operation. In Skim go to Skim->preferences, and go to the sync tab, tick the "Check for file changes" box and select Aquamacs Emacs as the preset option. Get Skim here http://skim-app.sourceforge.net/ 

Setting up Aquamacs:
Emacs has a rather ugly and convoluted way of changing options. The main hassle has been that Aquamacs doesn't have a preset way of easily doing (latex dvips ps2pdf) and also dvi viewing support in OS X is virtually non-existant, but we'll do some workarounds here.
If you want to fiddle around with any of the LaTeX options go to (once you have a .tex file open) LaTeX->"Customize AUCTeX".

Some settings I recommend is best pasted into the settings file. It is located at /Users/yourfolder/Library/Preferences/Aquamacs_Emacs/customizations.el open it in a text editor (not Aquamacs) and paste the following in after the line: " ;; If there is more than one, they won't work right."

'(LaTeX-command "latex -synctex=1")
 '(TeX-command-list (quote (("TeX" "%(PDF)%(tex) %`%S%(PDFout)%(mode)%' %t" TeX-run-TeX nil (plain-tex-mode texinfo-mode ams-tex-mode) :help "Run plain TeX") ("LaTeX" "%`%l%(mode)%' %t" TeX-run-TeX nil (latex-mode doctex-mode) :help "Run LaTeX") ("dviPS" "%(o?)dvips %d -o %f" TeX-run-command nil (latex-mode doctex-mode) :help "DVI->PS") ("ps2pdf" "ps2pdf14 %f" TeX-run-command nil (latex-mode doctex-mode) :help "Run AMSTeX") ("ConTeXt" "texexec --once --texutil %(execopts)%t" TeX-run-TeX nil (context-mode) :help "Run ConTeXt once") ("ConTeXt Full" "texexec %(execopts)%t" TeX-run-TeX nil (context-mode) :help "Run ConTeXt until completion") ("BibTeX" "bibtex %s" TeX-run-BibTeX nil t :help "Run BibTeX") ("View" "%V" TeX-run-discard t t :help "Run Viewer") ("Print" "%p" TeX-run-command t t :help "Print the file") ("Queue" "%q" TeX-run-background nil t :help "View the printer queue" :visible TeX-queue-command) ("Index" "makeindex %s" TeX-run-command nil t :help "Create index file") ("Check" "lacheck %s" TeX-run-compile nil (latex-mode) :help "Check LaTeX file for correctness") ("Spell" "(TeX-ispell-document \"\")" TeX-run-function nil t :help "Spell-check the document") ("Clean" "TeX-clean" TeX-run-function nil t :help "Delete generated intermediate files") ("Clean All" "(TeX-clean t)" TeX-run-function nil t :help "Delete generated intermediate and output files") ("XeLaTeX" "%`%l%(mode)%' %t" TeX-run-TeX nil (latex-mode context-mode) :help (format "Run X%sLaTeX" (string (decode-char (quote ucs) 600)))) ("Other" "" TeX-run-command t t :help "Run an arbitrary command") ("Jump To PDF" "(aquamacs-call-viewer \"%o\" %(FileLine) \"%b\")" TeX-run-function nil t :help "Jump here in Skim"))))
 '(TeX-output-view-style (quote (("^dvi$" "." "%(o?)dvips -Ppdf -G0 -ta4 %d -o && ps2pdf14 %f && open -a Skim.app %s.pdf") ("^pdf$" "." "open -a Skim.app %o") ("^html?$" "." "open %o")))))
(add-hook 'LaTeX-mode-hook
      '(lambda()
         (defun do-LaTeX ()
           "Compile LaTeX"
(interactive)
           (TeX-command "LaTeX" 'TeX-master-file))
(defun do-dvips ()
           "dvi --> ps (portrait)"
           (TeX-command "dviPS" 'TeX-master-file))
(defun do-ps2pdf ()
           "Compile ps2pdf..."
           (TeX-command "ps2pdf" 'TeX-master-file))
(defun do-comp-pdf ()
           "Compile LaTeX + dvips + ps2pdf..."
(interactive)
           (TeX-command "LaTeX" 'TeX-master-file) (TeX-command "LaTeX" 'TeX-master-file) (do-dvips) (do-ps2pdf))
         (local-set-key "\C-c\C-t\C-t" 'do-LaTeX)
         (local-set-key "\C-c\C-t\C-u" 'do-comp-pdf)
         ))

This part here "'(TeX-output-view-style (quote (("^dvi$" "." "%(o?)dvips -Ppdf -G0 -ta4 %d -o && ps2pdf14 %f && open -a Skim.app %s.pdf") ("^pdf$" "." "open -a Skim.app %o") ("^html?$" "." "open %o")))))" Makes sure that when you are not running pdflatex, ie. you are making dvi files when you try to view your output it is converted to ps and then to pdf.
'(LaTeX-command "latex -synctex=1") makes sure that the TeX file and pdf are syncronised so you can jump between them. This only works if you are using pdflatex.

The shortcut key for running latex on your tex file is "Control-c Control-c". In Emacs this is abreviated as C-c C-c. M is the meta key which on your keyboard should be "option" or "alt". 

To jump between your tex file and the pdf use "Shift"-"Command"-mouseclick. Use the same in Skim to jump from the pdf. This only works if you used pdflatex to make the pdf. But for a thesis you probably will since you can then use the hyperref package. The hyperref package is pretty cool, makes links within your pdf, so you can jump from your index to the section by clicking on the heading of the section in the index, and more.

Monday, January 18, 2010

LaTeX in your email with Thunderbird

A while ago I had a brilliant idea. I did a quick google search and couldn't find mention of it. WOW, how cool! Then I got home and had a proper look, not even that proper, and the idea has already been developed and deployed. Awwww... no unique idea for me. BUT the cool thing is you can write LaTeX equations in your emails in Thunderbird, and compile it so that the equations are included in your email as images.

This is so cool, I don't know why I haven't had this installed for ages. LaTeX equations IN Thunderbird. My implementation if possible would be slightly different. I'd like to have the LaTeX code sent and then the receiver can compile it. Then the receiver can edit the equations, and mail them back. Basically sending .tex files around, but Thunderbird should be able to compile basic LaTeX, and display it. I think this should be do-able.

Anyway, the add-on to Thunderbird is here:
 Download it, open your Thunderbird (if you don't have Thunderbird, get it here), find add-ons in the TOOLS tab, click install and select the .xpi file you downloaded. Restart Thunderbird and Bob is your proverbial uncle.