My notes bin

Where I keep my short notes of any topic.
Apr 18 '13

Tags: latex bibtex

Apr 17 '13

Tags: emacs orgmode

Nov 10 '12

Sep 17 '12

Enforce LaTeX to respect margins

Generally LaTeX tries to respect the margin settings. However, it may still violate the settings and overrun the margins, especially when there are inline equations in the text. To make LaTeX strictly follow the margin settings, put command \sloppy at the beginning of the document (right after begin document).

Tags: latex

Aug 15 '12

LaTeX: table columns with equal widths (or any specified width)

When writing my thesis, I created a table. However, some columns have unequal widths, which looks awful. So I used the paragraph column type (p) to specify their widths. The problem is that they are left-aligned while I want them centered.  I then used the array package and use the prefix specs >{\centering}, but it caused error due to the new line command (\) being changed. To fix this, you need to specify >{\centering\arraybackslash}. The final code is:

  \begin{tabular}{lc*{3}{>{\centering\arraybackslash}p{5em}}}    \toprule    & Total No. & \multicolumn{3}{c}{Interval between switchings of $u_{1}$ (min)} \\    \cmidrule(l){3-5}    & of switchings & Max & Min & Average \\    \midrule    Uncoordinated & 20 & 122.00 & 98.01 & 106.16 \\    Robust & 127 & 16.75 & 16.75 & 16.75 \\    Event-triggered & 92 & 46.23&19.65 & 22.99 \\    Self-triggered & 95 & 40.28 & 19.43 & 22.65 \\    \bottomrule  \end{tabular}

Tags: latex

Aug 9 '12

Jul 13 '12

Sharing LaTeX definitions with IPE pictures

This manual page instructs how to share LaTeX definitions (e.g. in your paper) with pictures created in IPE. However, that solution did not work for me. I figured out a simpler solution:

• In IPE, use menu “Help/Show Configuration” to see which directory is used for temporary LaTeX files; in my case, it is ~/.ipe/latexrun.
• Copy the LaTeX definition files that you want to use to that directory.
• In IPE, use menu “Edit/Document Properties” to edit the preamble to input these files.
• That’s it. Now re-LaTeX your IPE figures.

1 note Tags: ipe latex

Jul 10 '12

Tags: mac

Jun 16 '12

LaTeX’s delimiters are way too complicated

I’ve just discovered today that the way LaTeX handles delimiters, like (, ), [, ], is very very complicated.

Basically, those delimiters can be treated in two ways (or two types):

• Ordinary atoms: as the name suggests, they are just ordinary atoms and there is no special handling taken.
• Open and close atoms: they open and close some inner atoms, for example in cos(x), the delimiters ( and ) open and close the inner atom x OF the operator cos.

The visual difference may not be too obvious. In the first case (ordinary atoms), there is often some thin space before/after the delimiters. In the second case, there is none (space = 0). So, using the same example cos(x):

• Ordinary atoms: there is some thin space between ‘cos’ and ‘(’ and between ‘)’ and what follows. This is undesirable because it detaches the operator cos and its parameter.
• Open and close atoms: there is no space between ‘cos’ and ‘(’ and between ‘)’ and what follows. This is desirable because the contents inside the parentheses is the parameter of the operator cos.

Surprisingly, \left and \right produce ordinary atoms instead of open/close atoms.

• \left, \right, \big, \bigg, … produce ordinary atoms.
• (, ), [, ], \lvert, \rvert, \lVert, \rVert, \bigl, \bigr, \biggl, \biggr, … produce open/close atoms.

So, to summarize:

• Avoid using \left, \right after operators.
• After an operator (such as cos, sin, log, sum,…) whose parameters are the inner contents of the delimiters, use the plain delimiters or their <size>l, <size>r friends, so that open/close atoms are produced correctly.
• Note that the matrix environments (bmatrix, pmatrix,…) use \left, \right (producing ordinary atoms).
• The package mleftright might be of interest. It defines \mleft and \mright to produce open/close delimiters for \left and \right. It provides a command to re-define all \left and \right to \mleft and \mright.

References:

Tags: latex

Jun 14 '12

Tags: latex tikz