# why is the first column of the tabular environment not in alignment with the rest?

I would like to make a simple answer sheet that fits the width of an A4 paper. To make some space between the columns, I specify the width of each coloumn so that I can write answer key later on for ease of marking.

My question is: why the first column get topped, off the alignment of the other columns? It is slightly off the rest.

\documentclass[12pt, oneside, A4paper,final,leqno]{article}
\usepackage{amsmath, amssymb, latexsym, amscd, amsthm}
\usepackage{enumerate}
\usepackage[left=1.5cm,top=1.84cm,right=1.8cm,bottom=1.469cm,bindingoffset=0.05cm]{geometry}
\usepackage[mathscr]{eucal}
\usepackage{graphics, graphpap}
\usepackage{pstricks}
\usepackage{pst-eps}
\usepackage{pst-fill}
\usepackage{pst-node}
\usepackage{pst-plot}
\usepackage{pst-text}
\usepackage{pst-tree}
\usepackage{colortbl}
\usepackage{makeidx}
\makeindex
\usepackage{multicol,color}
\usepackage{indentfirst}
\renewcommand{\thefootnote}{}
\begin{document}

{\renewcommand{\arraystretch}{1.35752}
\bigskip
\begin{center}
\begin{tabular}{m{2.58cm}m{2.58cm}m{2.58cm}m{2.58cm}m{2.58cm}m{2.58cm}}\\
{\bf 1}\;\rule{1.362cm}{.4pt}&\;\;{\bf 6}\;\rule{1.362cm}{.4pt} &\;\;{\bf 11}\;\rule{1.362cm}{.4pt}&\;\;{\bf 16}\;\rule{1.362cm}{.4pt}&\;\;{\bf 21}\;\rule{1.362cm}{.4pt}&\;\;{\bf 26}\;\rule{1.362cm}{.4pt}\\
{\bf 2}\;\rule{1.362cm}{.4pt}&\;\;{\bf 7}\;\rule{1.362cm}{.4pt} &\;\;{\bf 12}\;\rule{1.362cm}{.4pt}&\;\;{\bf 17}\;\rule{1.362cm}{.4pt}&\;\;{\bf 22}\;\rule{1.362cm}{.4pt}&\;\;{\bf 27}\;\rule{1.362cm}{.4pt}\\
{\bf 3}\;\rule{1.362cm}{.4pt}&\;\;{\bf 8}\;\rule{1.362cm}{.4pt} &\;\;{\bf 13}\;\rule{1.362cm}{.4pt}&\;\;{\bf 18}\;\rule{1.362cm}{.4pt}&\;\;{\bf 23}\;\rule{1.362cm}{.4pt}&\;\;{\bf 28}\;\rule{1.362cm}{.4pt}\\
{\bf 4}\;\rule{1.362cm}{.4pt}&\;\;{\bf 9}\;\rule{1.362cm}{.4pt} &\;\;{\bf 14}\;\rule{1.362cm}{.4pt}&\;\;{\bf 19}\;\rule{1.362cm}{.4pt}&\;\;{\bf 24}\;\rule{1.362cm}{.4pt}&\;\;{\bf 29}\;\rule{1.362cm}{.4pt}\\
{\bf 5}\;\rule{1.362cm}{.4pt}&\;\;{\bf 10}\;\rule{1.362cm}{.4pt} &\;\;{\bf 15}\;\rule{1.362cm}{.4pt}&\;\;{\bf 20}\;\rule{1.362cm}{.4pt}&\;\;{\bf 25}\;\rule{1.362cm}{.4pt}&\;\;{\bf 30}\;\rule{1.362cm}{.4pt}
\end{tabular}
\end{center}
\end{document}

• Please add code to the beginning and end so that we get a complete LaTeX document that is possible to compile.
– pst
Jun 8 '15 at 6:04
– user10274
Jun 8 '15 at 6:15

It looks like you're using \; to insert a certain amount of whitespace. The \; directive is usually meant to be used exclusively in math mode. Interestingly, though, one or more of the many packages you load sort-of enable the use of this directive in text mode. However, there are some undesirable side effects of using \; in text mode, and you've discovered one of them. Just do a global search-and-replace of \;\; with $\;\;$, and the alignment problem should go away.

I couldn't help but observe that you have many repeated instructions in your table and that you're performing a lot of formatting work by hand that's more efficiently handled by LaTeX. Below is a suggestion for an alternate way for typesetting your table; you'll notice that it gets by with far fewer instructions.

\documentclass[12pt, oneside, A4paper,final,leqno]{article}
\usepackage[left=1.5cm,top=1.84cm,right=1.8cm,bottom=1.469cm,bindingoffset=0.05cm]{geometry}
\newcommand\myrule{$\;$\rule{1.362cm}{.4pt}}
\begin{document}

\begin{table}[h!]
\renewcommand{\arraystretch}{1.36}  %% "1.35752" seems speciously accurate
\setlength\tabcolsep{0pt}  % let LaTeX figure out the amount of inter-column whitespace
\begin{tabular*}{\textwidth}{l @{\extracolsep{\fill}} lllll}
\textbf{1}\myrule & \textbf{6}\myrule & \textbf{11}\myrule & \textbf{16}\myrule & \textbf{21}\myrule & \textbf{26}\myrule\\
\textbf{2}\myrule & \textbf{7}\myrule & \textbf{12}\myrule & \textbf{17}\myrule & \textbf{22}\myrule & \textbf{27}\myrule\\
\textbf{3}\myrule & \textbf{8}\myrule & \textbf{13}\myrule & \textbf{18}\myrule & \textbf{23}\myrule & \textbf{28}\myrule\\
\textbf{4}\myrule & \textbf{9}\myrule & \textbf{14}\myrule & \textbf{19}\myrule & \textbf{24}\myrule & \textbf{29}\myrule\\
\textbf{5}\myrule & \textbf{10}\myrule & \textbf{15}\myrule & \textbf{20}\myrule & \textbf{25}\myrule & \textbf{30}\myrule\\
\end{tabular*}
\end{table}
\end{document}

• could you make the number 10 in second column left aligned so that all the bars in this column in alignment? Jun 8 '15 at 7:22
• @Thumbolt - That's easy: just change the column type from l to r. (I set l in my code because left-alignment of the cell contents was what your original code performed.)
– Mico
Jun 8 '15 at 7:34
• How can I add alternating constrastive colour background in the space in columns? Sep 17 '15 at 2:52
• @Thumbolt - This is a new question; thus, please post a new query, stating clearly what kind of "alternating contrastiive colour background" you have in mind. A separate comment: To date, it looks like you've posted about ten queries on this site, received answers to almost all of them, yet formally accepted only one. It's very demotivating to potential writers of answers if the person posting the queries comes across as not bothering to acknowledge the time and effort needed to come up with answers.
– Mico
Sep 17 '15 at 4:26
• I want to have 3 colours for 6 columns, so that two adjacent ones are not the same. This helps student when they write their answers in. I can just vote, I dont know whether there is any buttom for accepting answers. Please tell me. I am happy with all the answers. Sep 17 '15 at 5:22

I'm not sure about your aim, but the column size you define by hand is wider than the contents, and this particularly shows on the right side.

Just use r columns, maybe increasing the intercolumn space as I do below.

\documentclass[12pt]{article}
\usepackage[left=1.5cm,top=1.84cm,right=1.8cm,bottom=1.469cm,bindingoffset=0.05cm,showframe]{geometry}
\usepackage{array}

\newcommand{\qrule}{~\rule{1.362cm}{.4pt}}

\begin{document}

\noindent
X\dotfill X

\begin{center}
\renewcommand{\arraystretch}{1.35752}

\begin{tabular}{@{}*{6}{r}@{}}
\textbf{1}\qrule&\textbf{6}\qrule &\textbf{11}\qrule&\textbf{16}\qrule&\textbf{21}\qrule&\textbf{26}\qrule\\
\textbf{2}\qrule&\textbf{7}\qrule &\textbf{12}\qrule&\textbf{17}\qrule&\textbf{22}\qrule&\textbf{27}\qrule\\
\textbf{3}\qrule&\textbf{8}\qrule &\textbf{13}\qrule&\textbf{18}\qrule&\textbf{23}\qrule&\textbf{28}\qrule\\
\textbf{4}\qrule&\textbf{9}\qrule &\textbf{14}\qrule&\textbf{19}\qrule&\textbf{24}\qrule&\textbf{29}\qrule\\
\textbf{5}\qrule&\textbf{10}\qrule &\textbf{15}\qrule&\textbf{20}\qrule&\textbf{25}\qrule&\textbf{30}\qrule
\end{tabular}

\end{center}
\end{document}


The showframe option is just to show the boundaries of the type block. Note the definition of \qrule that avoids burdensome typing and allows for fast change in the width. I removed all \; commands.

Note also the two @{} instructions to remove the intercolumn space at either end.

• could you make the gap between column wider because these gaps are to be put the answers in for marking tests. Jun 8 '15 at 7:16
• @Thumbolt Increase the amount in the \addtolength{\tabcolsep}{3pt} line, use 12pt or what you deem good Jun 8 '15 at 7:21
• For the first column, I mean questions from 1 to 5 and all the space around the 5 bars make one column. This is blue for instance, the next column that involves question 6 to 10 is olive. The next one is yellow. Etc. Sep 17 '15 at 7:11
• @Thumbolt Please, ask a new question. Sep 17 '15 at 8:03