0

I've used the following code to create a table. This is roughly what I want, and it looked close enough with a different page size.

Now with a new page size, the cells in the bottom right are too narrow. I need each of them to each have width = 1/8 of the overall table width.

Is there a better way to scale them according to a fraction of the page size?

\documentclass[letterpaper,10pt,english]{article}
\usepackage{tabularx}
\newcolumntype{Y}{>{\centering\arraybackslash}X}

\title{My Awesome Table}
\author{Kyle Gregory}
\begin{document}
\pagenumbering{arabic}
    \maketitle
    \begin{tabularx}{\textwidth}{| *8{Y} *8{Y} |}
        \multicolumn{1}{l}{\tiny $_{31}$} & \multicolumn{14}{Y}{ } & \multicolumn{1}{r}{\tiny $_{24}$} \\
        \hline
        \multicolumn{16}{| c |}{Reserved} \\
        \hline
        \multicolumn{16}{| c |}{\tiny N/A}  \\
        \hline
    \end{tabularx}
    \begin{tabularx}{\textwidth}{| *8{Y} *8{Y} |}
        \multicolumn{1}{l}{\tiny $_{23}$} & \multicolumn{14}{Y}{ } & \multicolumn{1}{r}{\tiny $_{16}$} \\
        \hline
        \multicolumn{16}{| c |}{Reserved} \\
        \hline
        \multicolumn{16}{| c |}{\tiny N/A}  \\
        \hline
    \end{tabularx}
    \begin{tabularx}{\textwidth}{| *8{Y} *8{Y} |}
        \multicolumn{1}{l}{\tiny $_{15}$} & \multicolumn{14}{Y}{ } & \multicolumn{1}{r}{\tiny $_8$} \\
        \hline
        \multicolumn{16}{| c |}{Reserved} \\
        \hline
        \multicolumn{16}{| c |}{\tiny N/A}  \\
        \hline
    \end{tabularx}
    \begin{tabularx}{\textwidth}{| *8{Y} |}
        \multicolumn{1}{l}{\tiny $_7$} & \multicolumn{6}{Y}{ } & \multicolumn{1}{r}{\tiny $_0$} \\
        \hline
        \multicolumn{4}{| Y |}{Reserved} & \multicolumn{1}{c |}{XPPS} & \multicolumn{1}{c |}{SROL} & \multicolumn{1}{c |}{ROG} & \multicolumn{1}{c |}{FRWL}  \\
        \hline
        \multicolumn{4}{| Y |}{\tiny N/A} & \multicolumn{1}{c |}{\tiny R/W (0)} & \multicolumn{1}{c |}{\tiny R (0)} & \multicolumn{1}{c |}{\tiny R (0)} & \multicolumn{1}{c |}{\tiny R (0)} \\
        \hline
    \end{tabularx}
\end{document}

Column type Y is defined as follows. I tried setting all of the columns as type Y, but I found that it would scale the \multicolumn{4} cells to be the same width as a single cell.

\newcolumntype{Y}{>{\centering\arraybackslash}X}

It produces the following output:

Table output

kjgregory
  • 101
  • please extend your code sniped to complete document beginning with \documentclass{...} and ending with \end{document} where in preamble should be loaded necessary packages and commands definitions. – Zarko Dec 14 '16 at 18:28
  • @Zarko is that better? – kjgregory Dec 14 '16 at 18:32
  • better, we are glad if you help us to help you :) – Zarko Dec 14 '16 at 18:36
  • Yes, that seems to do the trick. However, the text isn't centering in those corner cells anymore. I defined my new column type as \newcolumntype{M}[1]{>{\centering\arraybackslash}c{#1}} – kjgregory Dec 14 '16 at 19:13
  • in mentioned question was requested left aligned content in cel. for centering it, you should change\newcolumntype{P}[1]{>{\RaggedRight\arraybackslash}p{#1}} to \newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}} and than use lenghts as proposed in answer. – Zarko Dec 14 '16 at 19:19
  • Perfect! One last follow-on: Is there a way to define the newlength so that I can give it a number to get 1/8, 2/8, 3/8, etc. sized fields? Or do I have to define several length variables, e.g. \oneeigth, \twoeigths, \threeeigths, etc.? – kjgregory Dec 14 '16 at 19:28
  • 1
    If you have \oneeigth defined properly as a length, then you can use 2\oneeight, etc. – Pieter van Oostrum Dec 14 '16 at 19:38
  • Good idea, but didn't come out quite right due to not correctly taking into account the border wall paddings. – kjgregory Dec 14 '16 at 20:23

0 Answers0