Monday, November 8, 2010

Tunning your Latex in a Linux box

Whenever I install Latex, in particular the texmf installation that comes with Ubuntu, I always end up missing some style, class and bibliography files. In order to fix this, I always do the following:

  1. Copy the files' directories that I'm missing to /usr/share/texmf/tex/latex/ for styles (*.sty) and classes (*.cls); and to /usr/sare/texmf/bibtex/bst/ for bibliographic styles (*.bbt, *.bst)
  2. Make sure the directories are accessible for all users: chmod 755 -r /usr/share/texmf/tex/latex/ /usr/sare/texmf/bibtex/bst/
  3. Reload texmf with: sudo texhash
This always works for me whenever I do a fresh install and have to install the proprietary classes and styles from OSA, IOP and APS.

Revtex 4.1 needs particular attention in Ubuntu, as the natbib package in the current distro is the old natbib. In order to make available the new natbib I do the following:

  1. Download natbib.ins and natbib.dtx and all the .bst files from http://tug.ctan.org/tex-archive/macros/latex/contrib/natbib/
  2. Compile the instaler: latex natbib.ins
  3. Copy the result to a natbib folder in /usr/share/texmf/tex/latex/ for styles (*.sty) and /usr/sare/texmf/bibtex/bst/ for bibliographic styles (*.bbt, *.bst)
  4. Make sure the directories are accessible for all users.
  5. Reload texmf with: sudo texhash

Now, everything should be ready to use the nice features of natbib in Revtex4-1 like \cite{SomeCite, *SomeOtherCite} in order to put SomeCite and SomeOtherCite in the same reference number without having to do it by hand.

I hope you find this helpful.

Monday, March 22, 2010

How to keep processes running after logging out from a remote server...

Sometimes, the workstation at my desk is not enough for running a simulation and simultaneous on-line procrastination; enter the workstation or the cluster of our theoretical optics group.

While a cluster usually has a queue manager, a workstation usually lacks this software. In our case, both cluster and workstation lack a queue manager. Now, a queue manager usually keeps a process running in the remote server no matter what your logged status is. How to do the same without a queue manager? The answer is simple: nohup.

For simplicity's sake, I'm using an SSH connection to a linux machine if I want to leave a process running at the server and then log out I use the command:


nohup command_to_run &

Note that the ampersand symbol has to be issued in order to send the process to the background.

Say, for example, I want to leave the compiled binary file for a fortran program running in the remote server even if I log out:


nohup ./BinFile &


Or a matlab m-file script, please remind yourself to always add an exit command at the end of your script or you will end up with many matlab iddle processes running in the background:


nohup matlab -r MatlabScript.m -nodesktop -nojvm -nosplash &


Or a mathematica m-file function, again remind yourself to add an Exit[] command at the end of your script or you will end up with an iddle mathematica process running in the background:


nohup math -noprompt -run "<<MathematicaFunction.m" &

Usually, all the terminal messages from the processes are written to a file named: nohup.out



Wednesday, November 4, 2009

Resizing EPS files

Sometimes an eps file from my favourite plotting device (gnuplot, matlab, mathematica) is just to big for the arxiv and a png or jpeg file produced directly from the plotting device is just useless; in my experience the lettering produced like this pixelize most of the time.

I have tried different methods to produce nice and small figure files. So far, when an image files is just too big even for a journal submission I do the following,

  1. Arxiv, convert the nice looking eps into a png and use the png for submission. Pdflatex can handle png files.

    gs -r300 -dEPSCrop -dTextAlphaBits=4 -sDEVICE=png16m -sOutputFile=output.png -dBatch -dNOPAUSE input.eps

  2. Journal, try to rezise the nice looking eps. I take the output of the aforementioned code

    convert -quality=100 input.png output.jpg
    convert input.jpg esp2:output.eps

These are modifications on the solutions posted by Luke at Terminally-Incoherent, the Four Forces, the gs manual and the imagemagick manual. It seems png -> eps2 fails that's why png->eps3 or jpg->eps2 has to be used, it seems quite an old problem. I prefer jpg->eps2 as it produces smaller files than png->eps3 does.

If you have a better solution I'm eager to read about that.

NOTE: I found almost the same solution with a great discussion on the topic here.

UPDATE (March 23rd, 2010): I've started using GIMP to parse EPS files into smaller EPS files and PNG files, it seems the best alternative so far without the hassle of keeping gs and convert commands in my memory.

Saturday, October 17, 2009

How to embed a blog into a personal web page.

I've created a blog in blogger and now I want to embed it to my personal web page. After asking the intertubes about this question I decided to go with the iframe solution, although it is only xhtml-transitional and not supported in strict DTD. Here is my little how to.

1) (Optional) If you want, you can take out the navigation bar from blogger. Go to Layout>Edit HTML>Edit Template and add the following line of code.


#navbar-iframe {

   display: none;

}


2) Create an iframe at your personal web page to load the blog into it. The following code will do the trick,


<iframe id="myiframe" SRC="http://myblog.blogspot.com/" width="750px" height="400px" marginheight="0" frameborder="0" />



Just substitute the "myblog.blogspot.com" with the URL of your blog.

3) As you will notice, there will be a not so nice looking scrollbar on the right hand side of the iframe. In order to get rid of this scroll bar, John McKerrel has dealt with this and gives all the details on his blog here. Basically, to solve the problem you have to go to Layout>Edit HTML>Edit Template and include the following lines before the closing head tag,


<style type='text/css'>

     #inneriframe { position : absolute; top : 0px; left : 0px; visibility: hidden; }

</style>

<script type='text/javascript'>

      function test2() {

        var iframe = document.getElementById( 'inneriframe' );

        var wrapper = document.getElementById( 'wrapper' );

        var height = Math.max( document.body.offsetHeight, document.body.scrollHeight );

        iframe.src = 'http://www.mywebpage.org/iframetest-resize1.html?height='+height;

      }      

</script>


As you can see, you need to copy Jhon's file iframetest-resize1.html somewhere in your personal web page domain. This way your blog will be able to tell your page its height and your page will be able to resize the iframe accordingly.

Finally, add to your blog template the following line anywhere inside the body of the blog,


   <iframe height='10' id='inneriframe' width='10'/>


I put it just before the closing body tag.


I hope this is helpful for all those who are just looking for a simple solution without thinking on fulfilling strict DTD.