Friday, November 25, 2011

Table Notes

Tables can be used to attach tabular environments to captions. You can either use the caption command or simple plain text inside a table. The caption package is sometimes needed. Here is some examples:

\begin{table}
    blah
    \begin{longtable}{|l|}
      \hline
      a \\
      \hline
    \end{longtable}
  \end{table}

And an example of the caption

  \begin{table}
    \caption{\huge Section Header}
    \begin{longtable}{|l|}
      \hline
      a \\
      \hline
    \end{longtable}

This is a command to use the caption, but remove the prefix Table 1:

  \begin{table}
    \captionsetup{labelformat=empty,justification=raggedleft}
    \caption{\huge Section Header}
    \begin{longtable}{|l|}
      \hline
      a \\
      \hline
    \end{longtable}

Tables naturally float and here is some code to disable that

\begin{table}[!htbp]
    \huge
    blah
    \begin{longtable}{|l|}
      \hline
      \writetenrows
      %\writetenrows
      \hline
    \end{longtable}
  \end{table}

No page break doesn't work well with tables


In this code \nopagebreak has no effect when following a tabular environment. An option would be to use minipage to make this code work, but the problem with that is it would not let longtables span multiple pages as expected. A new solution is needed here

\documentclass{article}
\usepackage{longtable}
\newcommand{\writetenrows}{a \\ a\\ a\\ a\\ a\\ a \\ a\\ a\\ a\\ a\\}
\begin{document}
  \huge
  \begin{longtable}{|l|}
    \hline
    \writetenrows
    \writetenrows
    \hline
  \end{longtable}

  Section Header
  \nopagebreak
  \begin{longtable}{|l|}
    \hline
    \writetenrows
    \writetenrows
    \hline
  \end{longtable}
\end{document}

It seems that longtable accepts captions as long as they are followed by \\
This code seems to work, although the alignment is not working properly
Don't forget to include 'caption' in your package list
    \begin{longtable}{|l|}
      \captionsetup{labelformat=empty,justification=raggedleft}
      \caption{Blah}\\
      \hline
      \writetenrows
      \writetenrows
      \hline
    \end{longtable}
So here is what I have, it seems to tweak the font size slightly though for some reason.

\usepackage[justification=justified,singlelinecheck=false]{caption}
\begin{longtable}{!{\vrule width 1pt} #2 !{\vrule width 1pt}} 
  \caption*{\sectionfont EDUCATIONAL BARRIERS}\\