2

How can I set particular column widths in tabu? Here's what I have at the moment

{\tabulinesep=1.2mm
\begin{tabu}{|X|X|X|X|}
    \hline
        \textbf{Question} & \textbf{Solution} & \textbf{Partial Marks} & \textbf{Guidance} \\
    \hline
        %%%%%%%%%%%%%%% Q1 Equation of a Line
        1a & $\frac{1}{2}$ & A1 & cao \\
    \hline
        1b & $y-\frac{1}{3}x+4=0$ & A2 & cao \\
    \hline
        %%%%%%%%%%%%%%% Q2 Indices
        2 & $\frac{3^{2x}}{3^{2y}}=3^{2x+4}$ & M1 & Converts $9^x$ to $3^{kx}$ where $k$ is an integer \\
    \hline

which gives me this

enter image description here

I want to fix the size of the left-hand column and third column smaller than they currently are, while ideally leaving the other two alone. Any advice would be appreciated, thanks.

  • 2
    Using tabu is not a good idea. It is unmaintained and has unfixed issues: github.com/tabu-fixed/tabu#not-yet-handled – Henri Menke Feb 3 at 2:52
  • 2
    To make the first and third column narrower, use the l column type instead of X. – Henri Menke Feb 3 at 2:54
  • 1
    In addition to what @HenriMenke is saying: if you want to draw more attention to your question, provide us with a minimal working example that starts with \documentclass and ends with \end{document} and can be compiled. – user121799 Feb 3 at 4:32
3

As @HenriMenke has already pointed out in a comment, don't use the tabu package: it's buggy and it's unmaintained. Instead, I would suggest that you use the tabularx package and its eponymous environment. I would also recommend that you give the tabular material a much more open "look", mainly by omitting all vertical lines and using fewer, but well-spaced horizontal lines.

The following solution assumes that the overall width of the tabular material should be \textwidth. Since line-breaks don't seem to be useful or permissible in the first three columns, they use the l column type. Only the final column uses the X column type.

enter image description here

A final comment on the design of the table: Using boldface for the material in the header cells gives the table a rather "hefty" look -- but without actually improving its intelligibility and readability. If this were my table, I wouldn't boldface the words in the header row.

\documentclass{article} 
\usepackage{tabularx} % for 'tabularx' environment
\usepackage{booktabs} % for \toprule, \midrule, \bottomrule, and \addlinespace macros
\begin{document} 
\noindent
\begin{tabularx}{\textwidth}{@{} lll X @{}}
    \toprule
    \textbf{Question} & \textbf{Solution} & 
    \textbf{Partial Marks} & \textbf{Guidance} \\
    \midrule
    %%%%%%%%%%%%%%% Q1 Equation of a Line
    1a & $\frac{1}{2}$ & A1 & cao \\
    \addlinespace
    1b & $y-\frac{1}{3}x+4=0$ & A2 & cao \\
    \addlinespace
    %%%%%%%%%%%%%%% Q2 Indices
    2 & $\frac{3^{2x}}{3^{2y}}=3^{2x+4}$ & M1 & 
    Converts $9^x$ to $3^{kx}$ where $k$ is an integer \\
    \bottomrule
\end{tabularx}
\end{document}
  • Thanks for the advice, @Mico ! Unfortunately, I can't make the suggested changes in terms of format as I'm mimicking the format of preexisting documents. I was originally using tabularx but switched to tabu as I was having issues with the lines rows not being high enough (ie. the top and bottoms of fractions touching the hline). Do you have any suggestions how I could fix that? If so I'll definitely switch back to tabularx – Ljgrrgg Feb 3 at 20:25
  • 1
    @CharleyRobs - If you can't (or mustn't) use the well-spaced lines of the booktabs package, you could resort to inserting typographic "struts" to force a bit more space between the lines drawn by \hline and some of your numerator and denominator terms. See this answer to the query How to add vertical space struts after hline? for more information. – Mico Feb 3 at 20:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.