Will Price Posts About

LaTeX fails... and fixes!

I thought it might be a good idea to brush up my LaTeX skills by writing my maths homework in it… big mistake… lots of time wasted! I’m much more informed on LaTeX now, so here’s some of the things I struggled with in the hopes it will help future me from spending hours figuring out how to put multiple tables on one line!

Referencing figures and tables

You must put the label after the caption in a figure or table:

% Don't put labels before the caption, like here
    \caption{A table of things}

Multiple tables on a single line

Use the subcaption package, this allows you to specify the width of subtables and subfigures.

        $\circ$ & $e$ & $a$ & $b$ & $c$ \\
        $e$     & $e$ & $a$ & $b$ & $c$ \\
        $a$     & $a$ & $c$ & $e$ & $b$ \\
        $b$     & $b$ & $e$ & $c$ & $a$ \\
        $c$     & $c$ & $b$ & $a$ & $e$ \\
    %replace \quad with a new line if you don't want it on the same line
        $\circ$ & $e$ & $c$ \\

        $e$     & $e$ & $c$ \\
        $c$     & $c$ & $e$ \\
      \caption{Only valid $Z_4$ subgroup: $Z_2$}
    \caption{$Z_4$ and it's subgroup $Z_2$}

Specify the location of tables

[specifier] takes one of the following {h,t,b,p}

  • h - Here
  • t - Top
  • b - Bottom
  • p - Own page

These can be combined like hbp, close to the place in the text on it’s own separate page at the bottom

Spacing and measures

  • \quad - space
  • \linewidth - width of page, use this with the subtable environment when you’re setting the width of a subtable.