I was annoyed by a page break that appears if I \include{a portion of my document}. Using \input{} instead solves this.
Showing posts with label latex. Show all posts
Showing posts with label latex. Show all posts
Tuesday, November 19, 2013
Monday, June 3, 2013
LaTeX: draft class
Yesterday, while doing some unrelated stuff, I found out that it is useful to put \documentclass[a4paper][draft]{article} into the preamble sometimes, this shows the blocks of the document and can be really helpful if the layout is messed up.
Thursday, April 25, 2013
LaTeX: including a checkmark
$\rlap{$\checkmark$}\square$ or just $\checkmark$. I've been writing up a thesis report and wanted to mark the completed tasks, so there it is.
Monday, January 21, 2013
LaTeX: round citation parentheses w/ natbib
My colleague was very excited to find this out, as she's finishing her thesis these days. It might be remotely useful for me too, in distant future: http://tex.stackexchange.com/questions/63855/natbib-bibtex-how-can-you-show-the-bibliography-in-order-of-appearance-and-nu
Friday, December 28, 2012
Sunday, November 25, 2012
awk: making a LaTeX table from a csv file
I found this while digging through my master's notes, potentialy very useful.
awk ' {print $1," & ", $2, " & ", $3, " & ", $4, " & ", $13, " & ", $14} ' galaxies_Cat.txt > table.txt
Friday, September 7, 2012
making posters with LaTeX, rendering matplotlib images of right size
I'm doing a poster presentation next week in a conference, and I didn't want to use our default poster templates -- they just don't look pretty enough for me. So, I cooked my own, or rather lobotomised the baposter template by Brian Amsberg. It's quite customisable and well-documented. I was a web developer once so I get some masochistic satisfaction out of positioning, aligning and resizing stuff anyway.
Some things I learned underway, from matplotlib cookbook mostly:
For an A0 poster, getting image sizes and font sizes right is important. While compiling my .tex document, I inserted
fig_size was later set as a matplotlib parameter. If you specify .pdf as the filename extension, matplotlib generates a crisp file to be used as an image by LaTeX.
Some things I learned underway, from matplotlib cookbook mostly:
For an A0 poster, getting image sizes and font sizes right is important. While compiling my .tex document, I inserted
\showthe\linewidth command next to relative to text scaled images. It made LaTeX print out the image size in points in its hilarious output stream.
fig_width_pt = 628.62 # Get this from LaTeX using \showthe\columnwidth
inches_per_pt = 1.0/72.27 # Convert pt to inches
golden_mean = (sqrt(5)-1.0)/2.0 # Aesthetic ratio
fig_width = fig_width_pt*inches_per_pt # width in
fig_height = fig_width*golden_mean+0.3 # height in inches
fig_size = [fig_width,fig_height]
print fig_size
fig_size was later set as a matplotlib parameter. If you specify .pdf as the filename extension, matplotlib generates a crisp file to be used as an image by LaTeX.
Monday, August 27, 2012
Decent scientific plots with matplotlib
I think matplotlib is poorly documented and too object-oriented to be immediately usable. Trying to be too many things at once. Besides, the default values and default behaviour is kooky sometimes.
For instance, histogram bar widths: they are different for different datasets, and you cannot compare two distributions if that's the case. You have to resort to hacks like this:
So, what makes an ugly plot look decent? First of all, ticks:
Some parameters, redefining matplotlib's defaults (these plots are for printouts, so font sizes are big):
I would not claim the plots shown are publication-quality (just look at slightly differing histogram widths). But they look way better than default plots one would get with matplotlib.
For instance, histogram bar widths: they are different for different datasets, and you cannot compare two distributions if that's the case. You have to resort to hacks like this:
hist, bins = np.histogram(data, bins = 10)
width=1*(bins[1]-bins[0])
And I think it's a bloody hack, calling histogram method from some other module in order to be able to call matplotlib's histogram plotting routine.
Nevertheless. It's flexible and, since I already use Python to pull my data from databases, I decided to give it a try when I had to prepare some plots for a review poster. So, what makes an ugly plot look decent? First of all, ticks:
minor_locator = plt.MultipleLocator(plotTitles.yMinorTicks)
Ymajor_locator = plt.MultipleLocator(plotTitles.yMajorTicks)
major_locator = plt.MultipleLocator(plotTitles.xMajorTicks)
Xminor_locator = plt.MultipleLocator(plotTitles.xMinorTicks)
ax.xaxis.set_major_locator(major_locator)
ax.xaxis.set_minor_locator(Xminor_locator)
ax.yaxis.set_major_locator(Ymajor_locator)
ax.yaxis.set_minor_locator(minor_locator)
They have to be set separately for each axis, I pass them as parameters from a wrapper class.
Then, hatched bars. Some parameters, redefining matplotlib's defaults (these plots are for printouts, so font sizes are big):
params = {'backend': 'ps',
'axes.labelsize': 10,
'text.fontsize': 10,
'legend.fontsize': 10,
'xtick.labelsize': 8,
'ytick.labelsize': 8,
'text.usetex': True,
'font': 'serif',
'font.size': 16,
'ylabel.fontsize': 20}
If you'd like to have different symbols (markers) in a scatterplot, this is useful:
markers = itertools.cycle('.^*')
p1 = ax.plot(gd.data[0], gd.data[1], linestyle='none', marker=markers.next(), markersize=8, color=gd.colour, mec=gd.colour, alpha = 1)
But the double symbols in the legend, why is that? No sense.I would not claim the plots shown are publication-quality (just look at slightly differing histogram widths). But they look way better than default plots one would get with matplotlib.
RGB colours in matplotlib plots
LaTeX accepts un-normalised (like 0-65-122) rgb values as colour arguments in, say, .cls files:
\definecolor{AIPblue} {RGB}{0, 65, 122}
matplotlib insists on getting something like that:
#colour settings
ASColour = '#666666'
or normalised (0 - 1) rgb values tuple. It's easy to normalise, but it's also easy to convert rgb values to hex.
Forcing capital letters in Bibtex bibliography lists
Some bibliography styles eat the capital letters in article titles. To avoid this, one should include the letter in question in curly brackets, like {T}hat.
Thursday, May 24, 2012
Including source code in LaTeX document
It's possible to just paste it, by using \begin{verbatim}/\end{verbatim} commands. However, updating the source from the script directly is way neater . I use the listings package to do this.
Thursday, April 12, 2012
Latex degree symbol
Kelvins are official and basic, but I needed to make my students be aware of the conversion between Kelvin and Celsius scales.
I'll probably remember that, but will keep it here for digital posterity:
$^{\circ}$
Subscribe to:
Posts (Atom)

