Crazy or Creative

LaTeX Tips and Tricks

Posted in Tips And Tricks by sumitrangwala on 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

Posted in Tips And Tricks by sumitrangwala on 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

Posted in Tips And Tricks by sumitrangwala on March 9, 2009
  • Replacing text in a set of files

    :args
    :argdo %s/search/replace/ |w

SVN Tips and Tricks

Posted in Tips And Tricks by sumitrangwala on 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

Posted in Tips And Tricks by sumitrangwala on 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>