Use tmux or screen

screen or tmux is are terminal multiplexers that let you create multiple windows (and multiple panes in the case of tmux) and easily switch between them. This in itself is an extremely convenient feature to have on the console. They also allow you to keep the connection to a remote server alive, i.e. even if you disconnect from the server, you can resume your previous screen/tmux session when re-connect again.

I’m lazy so I only learn a few commands enough to get by; these commands are listed below.

Use screen instead. The control key of screen is Ctrl A
– screen -D -R : attach the active session (same as tmux attach)
– Ctrl – A – C : create new window
– Ctrl – A – 0, 1, … : switch to window number 0, 1 ,…

With tmux: the main hot key combination is Ctrl – B
– tmux attach : attach the active session (when there is only one)
– Ctrl – B – C : create a new window
– Ctrl – B – Shift – % : split the current pane vertically (into 2 panes)
– Ctrl – B – Shift – ” : split the current pane horizontally (into 2 panes)
– Ctrl – B – O : move around the panes
– Ctrl – B – 0,1,2,… : move to window number 0, 1 or 2
– Ctrl – B – [ : scroll mode  (q to exit )

I find several main advantages of tmux over screen (just using the out-of-the-box setting without any configuration — yes, I’m that lazy):

  • tmux can split a window into multiple panes — very useful when having a big display or when comparing things side-by-side.
  • tmux allows easy scrolling (with Ctrl – B – [ mode)
  • ctrl-A can still be used to move the cursor to the beginning of the current line (this happens an awful lot times due to the iterative nature of a data scientist’s work)

Installing LaTex packages on Ubuntu

One thing I find lacking for LaTex on Ubuntu is a package manager with automatic package installations. Every time a package is missing, I need to search for the package and install manually. The package must be placed in the right directory of the Tex distribution, which I often forget and don’t bother to remember. So I wrote this 2-line bashscript for myself. It only requires putting the .sty file in a pre-specified location (~/Downloads for me), and voila, the script will install the packakge automatically. So here goes


echo “Installing package ” $1

sudo mkdir -p /usr/share/texmf/tex/latex/$1
sudo cp ~/Downloads/$1.sty /usr/share/texmf/tex/latex/$1

sudo texhash

Save the above into a script e.g. “”.

Then when you need to install a package, just find its thepackage.sty file, place it in ~/Downloads (or modify the script to use your own location), run

./texinstall thepackage

then you’re good to go.

Better citations

Conferences typically have different citation styles. Personally I prefer a citation with author names and year, as the names can sometimes give indications of the paper content. For this citation style, the LaTex package natbib is a must.

I find this command simple yet most useful: \citep[see][chap 2]{nguyen2014} which yields (see Nguyen et al., 2014, chap 2). As a mnemonic, is for parenthetical. To provide citations without the parentheses, use \citet where t is for textual. 

Professional tables in LaTeX

Every time I write a paper, I learn new good tricks and practices with LaTex. This time it’s about creating professional looking tables in a publication. With the help of booktabs, it becomes a very simple task — took me a few glances to figure out how to use it.

The golden rule is to stop using \hline and \cline
– Replace \hline with \toprule, \midrule, \bottomrule for horizontal stretching lines across the table at the top, middle, and bottom of the table, respectively.
– To draw a line spanning a few columns, say 2 to 4, the old way is to use \cline{2-4}. The equivalent of this is \cmidrule{2-4}.