Latex Tips

Use ‘\tilde’ sparingly in your latex code before \cite, \ref etc. It will avoid annoying line breaking before a reference or an equation number. Similarly we should use ‘\’ after a period (‘.’), where the period symbol is not meant for ‘full stop’. For example, etc., e.g.  Otherwise, latex will interpret it as a full stop and will give more space between the words.

Title case problem with Bibtex

Using Jabref, a front end for bibtex, we can solve this problem quickly.

Q: BibTeX converts uppercase characters to lowercase in my title field. I know this can be prevented by wrapping uppercase letters in braces, e.g. “{T}he life cycle of {A}tlantic salmon”, but this is too much work. Can JabRef help?

A: JabRef has a setting that will automatically wrap all capital letters for certain fields in { } – this will make sure they are preserved in the LaTeX output. Under Options -> Preferences -> General -> File -> “Store the following fields with braces around capital letters”, make sure the title field is included. To do this for several fields, write e.g. “title;abstract” (without the quotes). This setting automatically adds braces when saving the bib file, but you won’t see the braces within JabRef.

source: http://jabref.sourceforge.net/faq.php

Some Latex tips for a IEEE Letter

The template for writing a double column IEEE letter is almost as same as the one for  IEEE transactions. For instance,

\documentclass[a4paper,journal]{IEEEtran}

is enough for writing a letter. But one is required to submit a single column version of the same during review which has tight constraints on number of lines and line spacing (depending on the particular research publication). The following declaration will be enough in general, (refer to IEEEtran for details on individual options)

\documentclass[12pt,draftcls,onecolumn,a4paper,journal]{IEEEtran}
The important one being the option of ‘a4paper‘, because IEEEtran loads letter mode by default rather than the a4 mode. This can mess your space constraints as it takes up more space.

Sometimes, even in this single column version, one needs to adjust the margins, so the number of lines in a page comes under a certain upper limit. Some tweaks in following piece of code should help for that
\newcommand{\CLASSINPUTinnersidemargin}{1in}

\newcommand{\CLASSINPUToutersidemargin}{1in}

\newcommand{\CLASSINPUTtoptextmargin}{1in}

\newcommand{\CLASSINPUTbottomtextmargin}{1in}

They adjust top-bottom and the side margins (it goes without saying this should be included before document class).

Above all, one should always refer to  IEEEtran-HowTo for any doubts in IEEEtran.

Using Latex in WordPress

This is a very much needed thing if we are using wordpress. The default latex syntax in wordpress is simple and straightforward  “dollar latex  YOURCODEdollar” (where dollar should be replaced by its symbol). Internally wordpress puts “YOURCODE” inside a ‘align’ environment. So whatever fits inside ‘align’ environment works. But the functionality of this basic latex support in wordpress is limited and rudimentary.

A popular and more functional alternative is Latex2Wp. Download and install it from here. (Interestingly,  it looks like most mathematicians use this plugin for blogs, for eg. Terence Tao).

Margin Issue in Latex

Today, while submitting my work in TENCON through edas.info, I faced an issue with the bottom margin.

Edas complained that the 3rd page has only 0.92 inch bottom margin where the minimum requirement was 1 inch.

I tried many things ……and wasted my time.

Then I found that TENCON asked for A4 paper and by default ieeetran gives LETTER format.

I simply changed documentclass[conference]{IEEEtran} to documentclass[a4paper,conference]{IEEEtran}, and the problem was solved!

Embedding All Fonts in PDF file

When we submit/send a pdf file, it is a good idea to embedd all fonts used, in the pdf file.

To embed all fonts in your pdf file use this command in terminal and create the pdf file from ps file.

ps2pdf -dEmbedAllFonts=true -dSubsetFonts=true -dEPSCrop=true -dPDFSETTINGS=/prepress FILENAME.ps

This will create a pdf file with name FILENAME.pdf

Hard word wrapping in gedit

gedit is a handy option for dealing ‘.txt. files.

Unfortunately, gedit does not contain any hard word wrapping plugin.

1. Open gedit
2. Navigate to Edit -> Preferences -> Plugins
3. Enable “External Tools”and press “close”
4. Now, go to “Tools” -> “Manage External Tools”
5. Press “New” (press ‘+’ sign) and enter “Line Break at Col 80″ (or any name you like)
6. Paste the following script in the “command(s)” text area (you can choose to leave out the #comments, these are only here as a reminder in case you want to modify it to fit your needs):

#!/bin/sh
BREAK=80
# fmt [-WIDTH][OPTION]… [FILE]…
# –uniform-spacing — one space between words, two after sentences
# –split-only — split long lines, but do not refill
# –width=WIDTH — maximum line width (default of 75 columns)
# when FILE is -, read standard input
fmt –uniform-spacing –split-only –width $BREAK –

7. Choose “Current selection” as Input
8. Choose “Replace current selection” as Output
9. At this point, you can choose to create a shortcut key such as “ctrl+m” for easy access.
10. Close “External Tools Manager” by pressing the “Close” button
11. Now this script is executable under the “Tools” menu. Alternatively, you can use your shortcut key for quick access.

My gedit version: 3.4.1, OS: Ubuntu 12.04 (64-bit)

Mex Error in Matlab

While using mex compiler in Matlab 2010+ versions, error occurs due to the conflict between tha shared libaries used by Matlab and the OS (mine is Ubuntu 11.10).

One of the solutions is to remove the Matlab shared libraries and use show the system shared libraries to Matlab.

This can be done by

cd $MATLAB
cd sys/os/glnx86
mkdir old
mv libstdc++.* libg2c.* libgcc_s* old

Then, update the library path

export LD_LIBRARY_PATH=/usr/lib32:/usr/lib:$LD_LIBRARY_PATH
source: http://www.mathworks.com/matlabcentral/answers/8079-how-to-get-working-matlab-coder-in-linux