## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ longtable / table column alignment Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
NChairFix
Posts: 7
Joined: Thu May 21, 2015 9:08 am

### longtable / table column alignment

I have been working on some manuals that display table in a longtable environment using a counter on a line.
A command has been created to fill in a row in the table for ease of use, this command has an optional argument and it would appear that that particular argument messes us the centering of the first column.
I have created a MWE below:


The only table that shows up correctly is the middle one, all the other tables have the first column non centered. In my document I use a 'longtable' however during creation on the MWE I realised that the normal table environment does it too, in some configurations, so I left that in!

Im sure it has something to do with the fact that the command \tablelineNOTWORKS has an optional parameter, but I don't understand why that would cause a problem.

I can get round this issue by using two commands instead of one clever one with an optional argument but I would still like to know why the problem exists, if possible.
Any ideas anyone?

Many thanks in advance

Tags:

rais
Posts: 235
Joined: Sun Nov 16, 2014 8:51 pm
NChairFix wrote:
\newcommand{\tablelineWORKS}[2]{	\doline{#1}{#2}}

a newline after an opening/closing brace is like entering a space character in the code.

does this look better?

KR
Rainer

NChairFix
Posts: 7
Joined: Thu May 21, 2015 9:08 am
Is that really all that it was?
Blimey! Well thank you for that it has indeed fixed my issue!

I take it that is why I keep seeing % after } all over other folks code? I assumed that the % and everything after it was just ignored, I take it the tex parser ignores EVERYTHING till the end of the line INCLUDING the end of the line character(s)?

rais
Posts: 235
Joined: Sun Nov 16, 2014 8:51 pm
NChairFix wrote:I take it that is why I keep seeing % after } all over other folks code?

Yes.
NChairFix wrote:I assumed that the % and everything after it was just ignored, I take it the tex parser ignores EVERYTHING till the end of the line INCLUDING the end of the line character(s)?

Yes, it won't put a space character in the result.
Consider this small sample:
\documentclass{article}\begin{document}a     b%     c\end{document}

You should see a bc' in the output: the newline after the a' character inserts a space, the spaces before the b' and c' characters are ignored (at the beginning of their respective lines), and the space (from newline) after the b' is commented out.

KR
Rainer

Johannes_B
Site Moderator
Posts: 4044
Joined: Thu Nov 01, 2012 4:08 pm
rais wrote:
\documentclass{article}\begin{document}a     b%     c\end{document}

I have seen people do the following wondering themselves thy there is a space, even though the end of line is commented out.
Of course, those spaces are counted.
\documentclass{article}\begin{document}a     b%     c    %d\end{document}`
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

NChairFix
Posts: 7
Joined: Thu May 21, 2015 9:08 am
This it all makes perfect sense and is all quite logical now you mention it, I guess it is something else to get used to and look out for in the future.