Skip to content

LaTeX Tips and Tricks

March 9, 2009
  • Interactively setting a variable

    Add similar lines before \documentclass

    \typeout{Please enter a value for var}
    \typein{\var}{var=}
    
  • Including pages from other PDF documents

    \usepackage{pdfpages}
    ........
    \begin{document}
    \includepdfset{pages=-}
    \includepdf{cv.pdf}
    \includepdf{pubication1.pdf}
    \includepdf{pubication2.pdf}
    

    pdfpages provides lot of flexibility with selective
    inclusion of pages, landscape mode, etc.

  • Adding directories to package search path
    (from Paul Jolly)

    % The trailing colon indicates the standard search
    % path should be appended to the user specified
    % TEXINPUT variable
    
    % Paths are ':' separated
    export TEXINPUTS=".:~/path/to/add:"
    export TEXINPUTS=".:~/path/to/add:/second/path/to/add:"
    
    % Trailing '/' for directories is optional
    export TEXINPUTS=".:~/path/to/add/:"
    
    % double trailing slash indicates this directory is
    % to be search recursively
    export TEXINPUTS=".:~/path/to/add//:"
    
  • Input files with relative path

    \input and \include are well known commands for
    preparing larger documents from smaller files. However, if
    these smaller sections of text are organized within a
    directory with its own \input, \include,
    \includegrapics, etc., \input won’t work. For such
    cases, LaTeX package import can help.

    \usepackage{import}
    \import*{/play/act1/}{act.tex}
    

    On encountering \input{scene1.tex} in act.tex, LaTeX
    will now search for scene1.tex in /play/act1/ in addition to
    the local directory

  • Embedding fonts

    Give -dPDFSETTINGS=/prepress option to ps2pdf and
    verify final output with pdffonts

    In my case, gnuplot was the culprit that was not
    embedding the fonts in figures. A more effective but
    time-consuming way of correcting it is to specify tex
    font file to gnuplot as specified
    here
    or in more details here

Firefox Tips and Tricks

March 9, 2009
  • Editing textarea with your favorite editor

    Very often one would prefer to write in a text area on the web using
    ones favorite editor. For example, if you use Gmail you might like to have
    the power of vim or emacs while composing mails. You can do that with
    It’s All Text that displays an edit button that pops up your
    favorite editor.

    • Getting it to work with cygwin and vim
      Create a file gvim.bat (in notepad) with the following text

      @echo off
      C:\cygwin\bin\run.exe -p /usr/X11R6/bin gvim -display
      127.0.0.1:0.0 %*
      

      set editor to C:\path_to_gvim.bat

  • Quickly accessing commonly used bookmarks

    Use keyword bookmarking. Access any bookmark’s property ( Ctrl+Shift+B
    and then the bookmark you are interested in or right click toolbar
    bookmarks and then Properties) and set keyword for any character or
    sequence of characters. Now you can access this bookmark by pressing
    Alt+D or Ctrl+L (to jump to the address bar) character [Enter].
    Further customization with string substitution is possible. However,
    using keyword with bookmarklet is still an issue.
    More Information

Vim Tips and Tricks

March 9, 2009
  • In order to replace a text in a set of files

    :args <list of files>
    :argdo %s/search/replace/ |w
    
  • Adding simple syntax highlighting on the fly

    Using the syntax command, syntax rules can be added to vim
    to improve readability of the file. While there are many
    options available (see :h syntax), I found the syntax
    region
    option fit for my use. Say we want to turn every
    line starting with ** into a different color. We can do
    that using command

    :syntax region Nontext start="^\*\*" end="$"
    

    The above command says that any line starting with **
    should be displayed in the color pattern as defined by the
    group-name Nontext. A syntax region description like
    above needs to specify a start pattern (a regex) and an
    end pattern (another regex). In the example above the
    start pattern is ^**, i.e., any line starting with **
    and the end pattern is $, i.e., end of line. (since *
    needs to be escaped in vim, a regex ^** becomes ^\*\*
    in the above example). Vim has some standard color names
    define that can be used to define the appearance of
    selected region. Try :hi to list all the group-name and
    how they would look on the current terminal. This example
    uses on of the standard group-name define as Nontext.

    Recently, I had to submit some reviews and I choose to
    submit it using a text file (reviews.txt) provided to
    me. The file has a large number of section in the
    following format:

    @paper: xyz
    @type: paper
    \*\* SOME TITLE:
    @T1
    <replace with one or more lines of review text>
    @@
    \*\* SOME TITLE:
    @T2
    <replace with one or more lines of review text>
    @@
    

    In order to quickly identify places that I need to add
    text, I added the following lines to a file (hi.vim)

    syntax region Nontext start="^\*\*" end="$"
    syntax region Question start="^@" end="$"
    syntax region Diffchange start="^-" end="$"
    

    and edited by file by opening it as

    gvim -S hi.vim review.txt
    

    Try it and the usefulness of these line will be apparent.

SVN Tips and Tricks

March 9, 2009
  • Avoid typing long svn commands by defining appropriate function in your
    .bashrc

    export SVN_PATH="svn+ssh://path_to_svn/trunk"
    function sl () { svn ls ${SVN_PATH:?"SVN_PATH is not unset
    or empty"}/${1:?"Insufficient arguments"}}
    

    You can now list trunk/projects as

    sl projects
    

Bash Tips and Tricks

March 9, 2009
  • Using CDPATH can save a lot of keystrokes. CDPATH is to cd what
    PATH is to command completion. For example,

    export CDPATH=.:/home/joe/projects:
    

    will allow you to cd into a directory /home/joe/projects/wordpress from
    any directory using

    cd wordpress
    
  • $'STRING' can help you print anything you wish. In STRING escape
    ' by \'

    $> echo $'foo\'bar'
    foo'bar
    
  • Check variables as

    ${VAR_NAME?"VAR_NAME is not defined"}
    ${VAR_NAME:?"VAR_NAME is not defined or empty"}
    
  • bash_completion allows you to go beyond command completion to listing
    options available for the command. For example, on the latest version of
    unbuntu (8.04) add source /etc/bash_completion to your .bashrc. If
    subversion is installed on your machine then $> svn <tab> will
    list all possible options in svn as:

    add        co         -h         log        pedit      proplist   rm
    annotate   commit     help       ls         pget       propset    status
    blame      copy       --help     merge      plist      pset       switch
    cat        cp         import     mkdir      praise     remove     unlock
    checkout   delete     info       move       propdel    rename     update
    ci         diff       list       mv         propedit   resolved   --version
    cleanup    export     lock       pdel       propget    revert
    

    It supports many other commands. It’s auto-completion of
    directories on a remote server for scp is really useful.

  • Prevent annoying ssh disconnection by

    alias ssh='ssh -o TCPKeepAlive=no -o ServerAliveInterval=15
    -o ServerAliveCountMax=10'
    

    Alternatively, you can set these options in your ssh_config ($>
    locate ssh_config
    ) file. You can also try

    alias ssh='ssh -o TCPKeepAlive=yes
    

    But it didn’t work for me. For further information and for putty
    settings see

    http://drupal.star.bnl.gov/STAR/comp/sofi/facility-access/ssh-stable-con

  • Bash has some lesser know command that provides exactly what you might
    sometimes be looking for. A quick read of info coreutils is recommended.
    Few such commands are

    • pr can help you paginate or columnate text. For example,

      pr -2 <filename>
      

      will generate a two column output of the text with page boundaries
      delimited with page headers and footers

    • paste to concatenate files vertically

    • tac to concatenate files in reverse order.

      tac <filename>
      

      to print file <filename> in reverse order

    • Get a quick directory overview to a depth of <n>

      tree -L <n> <dir_name>
      

Online Lectures, Talks, etc.

March 8, 2009

What Google Needs

January 28, 2009

Google Search

  • Ability to search an image similar to a given image.
    • Today, we enter text and expect Google to list all the sites containing that text. A natural extension to this would be to upload an image and get all websites having a similar image. Applications could range from (a) finding all websites that use a trademark image to (b) Finding details about a personality (place, paintings, etc.) by her/his (its) picture. (I recently (Feb. 2009) attended a talk by Kilian Weinberger from Yahoo Research on machine learning techniques to accomplish it.)
  • Purging invalid links and associated cache
    • An option, say “Check link validation”, in Google search to let users inform Google that a site is no more valid. Google says it’s crawler would detect it but I have seen invalid links (and its cached copy) on Google for months.

(Note: Many, including Google, have compiled features list, but I have compiled here the ones I didn’t find on (at least) the ones I browsed.)

Travel Tips

December 30, 2008

Buying Tickets

A list of sites to search for an air ticket

While waiting for the flight

  • Price Check
    • Yapta
      After purchasing a ticket mail it to flights@yapta.com and yapta
      will tell you whenever the prices go down to claim a credit.
  • Seat Selection and Trip Planning
    • SeatGuru
      Get reviews to pick us the best available seats.
    • checkmein
      Paid service, currently restricted to few airlines, that checks in
      as per user’s preferences when online check in begins.
    • TripIt
      Mail your complete itinerary to Tripit which compiles it in a
      single file with addition information that you might require
      during the trip.
  • Flight Status
  • Miscellaneous
    • FlyingFees
      Find out about baggage policies and fees for various airlines.

Refunds

India Specific

Travel Agent

Domestic (India)

Recommendations for Elevator Design

November 23, 2008

Feature recommendations

  • The open door switch should be color coded (so that next time we
    want to help someone we can find the switch to press before it’s too
    late.)
  • A switch to deselect a floor if one accidentally selected it.

Next Generation Travel Sites

August 28, 2008

Current Solution

You plan a trip. You break it down into air travels, hotels, etc. for
each city and search the best deals for each of one them.

Better Solution

Instead you build a complete itinerary of your trip including when you
would like to visit a city, places you would visit in the city, a radius
within which you would like to stay (or this could be calculated
optimally from other data), hotel preferences, duration of the stay,
etc. The site then finds the best deal for the complete trip.

Follow

Get every new post delivered to your Inbox.