Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The code and output shown below are based on the answers to this post .

The problem is that first of the three tables is produced as desired but the second and third have the second column vertically centered which is not desired. This is despite the fact that all three are the same except for the use of macros in the second and third to reduce redundancy. Somehow the introduction of these macros has changed the output. What is going on? How can I fix that?

\documentclass{article}
\usepackage{multicol}
\usepackage{enumitem}
\usepackage{tabu}
\usepackage[table]{xcolor}

\begin{document}

This table just repeats all the required commands
for each row.  The output appears as desired.

\begin{center}\small
\setlength{\columnseprule}{.4pt}
\renewcommand\columnseprulecolor{\color{blue}}
\begin{multicols}{2}

\begin{tabu} {>{\bfseries}lX}
\savetabu{mytabu}
Name1 & Value1. \\
\tabucline[blue]-
\end{tabu}

\begin{tabu} {\usetabu{mytabu}}
Name2 & Value2. \\
\tabucline[blue]-
\end{tabu}

\begin{tabu} {\usetabu{mytabu}}
Name3 & Value3. \\
\tabucline[blue]-
\end{tabu}

\end{multicols}
\end{center}

This table uses the RowA macro defined using a \LaTeX{} macro.  The second
column of the table is vertically centered which is not desirable.

\newcommand{\RowA}[1]{
    \begin{tabu}{\usetabu{mytabu}}
    #1 \\
    \tabucline[blue]-\end{tabu}
}

\begin{center}\small
\setlength{\columnseprule}{.4pt}
\renewcommand\columnseprulecolor{\color{blue}}
\begin{multicols}{2}
\raggedcolumns

\begin{tabu} {>{\bfseries}lX}\savetabu{mytabu}
Name1 & Value1. \\
\tabucline[blue]-
\end{tabu}

\RowA{Name2 & Value2.}

\RowA{Name3 & Value3.}

\end{multicols}
\end{center}

This table uses the RowB macro defined using a \TeX{} macro.  The second
column of the table is vertically centered which is not desirable.

\def\RowB#1{
\begin{tabu} {\usetabu{mytabu}}
#1 \\
\tabucline[blue]-\end{tabu}
}
\begin{center}\small
\setlength{\columnseprule}{.4pt}
\renewcommand\columnseprulecolor{\color{blue}}
\begin{multicols}{2}
\raggedcolumns

\begin{tabu} {>{\bfseries}lX}\savetabu{mytabu}
Name1 & Value1. \\
\tabucline[blue]-
\end{tabu}

\RowB{Name2 & Value2.}

\RowB{Name3 & Value3.}

\end{multicols}
\end{center}

\end{document}

screenshot

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Standard answer to a large percentage of TeX questions:

Missing % at end of lines.....

\newcommand{\RowA}[1]{%
    \begin{tabu}{\usetabu{mytabu}}%
    #1\\%
    \tabucline[blue]-\end{tabu}%
}


\def\RowB#1{%
\begin{tabu} {\usetabu{mytabu}}%
#1\\%
\tabucline[blue]-\end{tabu}%
}
share|improve this answer
    
Thanks. That works. Why is it needed? Also why is it that the Row macro in this post tex.stackexchange.com/questions/62642/multiple-pairs-of-columns/… works without trailing % characters? –  user1189687 Jul 10 '12 at 13:34
    
The question referenced also inserts lots of spurious space characters, if they had no effect in the output, it just got lucky. –  David Carlisle Jul 10 '12 at 13:55
    
I understand the difference between putting in trailing % characters and not (i.e. whitespace swallowing) but don't understand why it should matter when the first table shown in my question that does not use macros has no trailing % characters. –  user1189687 Jul 10 '12 at 14:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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