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.

I have got the following two-column longtable for items in my CV:

\begin{longtable}{ r l }
...
\end{longtable}

Now the problem is: The second column containing the job descriptions is aligned quite fine, whereas the first column does not respect its right alignment although it only contains simple text (the dates) generated by some \ifstrequal commands to allow for special cases like (.. - present).

Can anyone point me in the right direction please?

\documentclass[11pt]{article}

\usepackage{color}
\usepackage{xifthen} % provides \ifthenelse and \isempty
\usepackage[none]{hyphenat}
\usepackage{geometry} 
\usepackage[parfill]{parskip}
\usepackage{sectsty} 
\usepackage{array}
\usepackage{etoolbox}
\usepackage{longtable} 

\geometry{a4paper} 
\geometry{margin=2cm} 
\pagestyle{empty} 

\providecommand*{\cvitem}[4][]{
    \ifstrequal{#3}{-}{#2 – present}{
            \ifstrequal{#2}{#3}{#2}{
                #2 – #3
            }
    } & \parbox[t]{12.3cm}{ \raggedright
                \textbf{#4} 
                    \ifthenelse{\isempty{#1}}{}{  \\ #1 } % Only output second line if optional parameter given
            \\[0.5cm] }  \\
}

\begin{document}

\begin{longtable}{ r l }
    \cvitem[foobar]{08/2011}{-}{foobar}
    \cvitem[foobarfooba]{04/2008}{08/2011}{foobar}
    \cvitem[foobar]{09/2006}{08/2007}{foobar}
    \cvitem[foobar]{08/2005}{08/2005}{foobar}
    \cvitem[foobar]{03/2005}{03/2005}{foobar}
    \cvitem[foobar]{05/2004}{05/2004}{foobar}
    \cvitem[foobar]{03/2004}{12/2005}{foobar}
\end{longtable}

\end{document}
share|improve this question
2  
Welcome to TeX.SE. While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. In this case it probably has something to do with how your using \ifstrequal. –  Peter Grill Jul 5 '12 at 20:51
    
Not the cause but I wouldn't use proportional figures for the dates. Your 1 is clearly narrower than the other figures. It ain't look right boie. –  Marc van Dongen Jul 5 '12 at 20:57
6  
You should always post complete documents that can be run it's very hard to help given no information. Firstly have you run latex a few times (longtable does not line up on the first time) otherwise the most likely cause is spurious space characters and the traditional cause of those is missing % at ends of lines in macro definitions. But impossible to say. –  David Carlisle Jul 5 '12 at 21:00
    
Thanks for all your helpful comments so far. Here is my MWE showing the problem: dl.dropbox.com/u/133332/MWE.tex Please note: As I am using a special font installed on my system, I use XeTeX and the fontspec package. Removed it in the MWE, ran with LaTeX and the problem persists, so it seems to have nothing to do with which font is used. @DavidCarlisle: I've run latex dozens of times, no change in the output. –  David Jul 6 '12 at 9:09
    
You can edit your question to add the text directly (I did it in this case) Note unrelated to the alignment your use of – to get an n-dash is non standard and won't work in general, the standard markup for that is -- –  David Carlisle Jul 6 '12 at 9:21
show 4 more comments

1 Answer

up vote 3 down vote accepted

As predicted in the comments, your macro is adding a lot of spaces.

\providecommand*{\cvitem}[4][]{
    \ifstrequal{#3}{-}{#2 – present}{
            \ifstrequal{#2}{#3}{#2}{
                #2 – #3
            }
    } & \parbox[t]{12.3cm}{ \raggedright
                \textbf{#4} 
                    \ifthenelse{\isempty{#1}}{}{  \\ #1 } % Only output second line if optional parameter given
            \\[0.5cm] }  \\
}

adds many space tokens, it needs to be

\providecommand*{\cvitem}[4][]{%
    \ifstrequal{#3}{-}{#2 – present}{%
            \ifstrequal{#2}{#3}{#2}{%
                #2 – #3%
            }%
    } & \parbox[t]{12.3cm}{\raggedright
                \textbf{#4}%
                    \ifthenelse{\isempty{#1}}{}{\\ #1}% Only output second line if optional parameter given
            \\[0.5cm]}%
}
share|improve this answer
    
Thanks very much, solved the problem perfectly! And thank you all for being patient with me ;) –  David Jul 6 '12 at 13:15
add comment

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.