Currently Solicitating Content Suggestions for a LaTeX Seminar

LaTeX (pronounced Lay-Tek) is a powerful document preparation language developed by and for scientists for writing manuscripts, journal articles, and even presentations. I’ve blogged about various aspects before here and  here on Upsection.

My advisor and I are currently organizing an Intro to LaTeX seminar for grads and u-grads here at McGill. Content we’re planning on covering includes:

  • Getting started with LaTeX (selecting and installing TeX software) 
  • General journal formatting, templates, dictionaries, and style files 
  • Figures and captions 
  • Tables 
  • Equations and special characters 
  • Building your reference library 
  • Resources, help, and cheatsheets 
  • Adapting your manuscript to McGill’s LaTeX thesis template (something I’ll be doing soon and I’m sure other MSc and PhD students will be interested in).

Are there any topics we’re missing? The purpose of the seminar is not to be all-encompassing, but to provide enough direction and resources to get students started with using LaTeX.

So what helped you when you started using LaTeX? Any tips or advice we should share with our students? Let us know in the comments!

Advertisements

LaTeX Tables Primer

I held off on posting this so that I didn’t have too many LaTeX posts in quick succession. Grab an effective LaTeX template, or learn why you should start using LaTeX.

So you’ve started using LaTeX, but you’re stuck trying to put your data into a table. Tables in LaTeX are THE most un-intuitive, poorly designed part of the otherwise slick and clean document prep software. When I first tried putting tables into docs, I did everything I could to avoid making tables. Eventually, importing snipped word/excell tables into LaTeX as images just wouldn’t cut it. I had to make a table.

So let’s get started. Open up a new LaTeX doc, I’m using my custom template that you can grab HERE. Get rid of the table of contents and the second section code. We’re going to begin by setting the bounding code that will tell our table how to look:

begin{table}[ht]
        begin{center}
                  begin{tabular}{| c | l | l |}

                  end{tabular}
        end{center}
caption{small{Look at this bitchin’ table!}}
label{table}
end{table}

After begin{tabular} there is a bracket with {| c | l | l |}. This code tell LaTeX how to justify text/images within columns and where to draw vertical lines separating columns. This gives you infinite freedom in how you want to design your table. You can make anything from this:

to this (using code {| c | l  r |}:

Why I’m keeping track of what my neighbor eats, aside, we have two very different tables from only a little change in code.

So now that we have our table style made, let’s input some data.

begin{table}[ht]

        begin{center}
                  begin{tabular}{| c | l | l |}
hline
                                      Bills & Amount & Paid?
                                     Rent & $475.00 & Yes
hline
                                     Electricity & $16.00 & Yes
hline
                                     Water and Gas & $30.00 & Yes
hline
        end{center}
caption{Look at this bitchin’ table!}
label{table}
end{table}

                  end{tabular}

Okay, let’s walk through the code. hline makes a horizontal line the width of your column. Column width is governed by th elength of text you have in a specific column, more on that later. Columns are separated from one another using the & command. The double backslash you see at the end of each line tells LaTeX to start a new row. We can separate rows nicely(and close off the bottom of our column) with another hline command.

So let’s talk about the problems with LaTeX tables. If we take a column with a lot of text in it, like…

begin{table}[ht]

        begin{center}
                  begin{tabular}{| c | l | l |}
hline
                                      Bills & Amount & Paid?
                                     Rent & $475.00 & Yes
hline
                                     Electricity & $16.00 & Yes 
hline
                                     Water and Gas & $30.00 & Yes
hline 

                                    Money I owe my neighbor for walking my dog while I was on vacation in Tahiti enjoying cheap beer and beautiful women while soaking in the sun and laughing at how my neighbor is cleaning up after my dog & $20.00  & No 

 hline
        end{center}
caption{Look at this bitchin’ table!}
label{table}
end{table}

                  end{tabular}

…will give us something like this:

Not bitching.

So how do we fix it? What we have to do is look at the pdf and make an educated guess at around what word we need to start a new row. Once we have that word, we type “& &” then to bring it to the next row.

The double “and” command tells the table that we’ve made it to the far side of the table, but we want those last columns to be blank.

The double backslash drops us to the next row.
So with this code:

begin{table}[ht]

        begin{center}
                  begin{tabular}{| c | l | l |}
hline
                                      Bills & Amount & Paid?
                                     Rent & $475.00 & Yes
hline
                                     Electricity & $16.00 & Yes 
hline
                                     Water and Gas & $30.00 & Yes
hline 

                                    Money I owe my neighbor for walking my dog while I was & &on vacation in Tahiti enjoying cheap beer and beautiful women& & while soaking in the sun and laughing at how my neighbor is& & cleaning up after my dog & $20.00  & No 

 hline
        end{center}
caption{Look at this bitchin’ table!}
label{table}

  end{tabular}

end{table}

                

 We get this:

bitching.
So use to divide up text and make your table the appropriate size. Don’t forget to add in & & for blank columns.
There ya have it, LaTeX tables are annoying to make, especially when you have a large amount of text for each column, but now at least you have a fighting chance of making it work.

An Effective LaTeX Template

EDIT: There was an error with the lineno package call in this template, it has been fixed.

I wrote a guest post for HackCollege about why students (or anyone, profs, ect.) should switch to using LaTeX to write documents. I’d like to include in this post my go-to template for almost every document I write (including my undergrad thesis). It’s adapted from a template my undergrad thesis adviser, Christie Rowe, used, with a couple extra bells and whistles. It’s primarily set up for writing science papers, but will work great for any research paper. It’s set up to use bibtex citations. Click this link to download the template.

Install it wherever your LaTeX software requires. For TeXworks, install it to the specified user directory when you first opened TeXworks.

Now that I’m thinking about LaTeX, the hardest, most frustrating part for me was getting tables to work nicely. It’s a pain in the ass, especially if you’re trying it for the first time. Coming soon in a future article: LaTeX tables primer.

If you get stuck and aren’t sure what code you need, I highly recommend the LaTeX wikibook. Especially the chapter on bibilography management.