I have a tabularx with 4 columns and 2 2-3 rows. The problem is that even though the first row behaves as expected, the second one doesn't. I am trying to set the 3rd column right aligned and the 4th column center. However, I cannot get it to work on all rows. I have created a minimum sample, that shows both my setup and my problem.
In the sample code, I am creating two tables, just to show the differences.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\usepackage{tabularx} % Til tabeller der tilpaser sig i bredden
\newcolumntype{R}{>{\raggedleft\arraybackslash}r}
\usepackage{xifthen} % Used to test if an argument is empty
\usepackage{datetime} % Used to format dates
\newdateformat{timeLineDate}{\THEDAY.~\shortmonthname~\THEYEAR}
\newdateformat{monthYearDate}{\monthname[\THEMONTH]~\THEYEAR}
\newcommand{\createPerson}[9]
{
\begin{tabularx}{\textwidth}{lXRc}
Navn: & #1 & \formatdate{#4}{#5}{#6} & $\star$\\
\ifNoArgumentElse{#2}{Kaldenavn: & #3}{Fødenavn:}& \ifNoArgumentElse{#7#8#9}{&}{
\ifNoArgumentElse{#7}{
\ifNoArgumentElse{#8}{#9}{\monthYearDate\formatdate{1}{#8}{#9}}
}{\formatdate{#7}{#8}{#9}} & \cross
}
\ifNoArgumentElse{#2}{}{\\Kaldenavn: & #3 &&}
\end{tabularx}
}
%Arguments
% 1) The argument to test
% 2) If empty then do this
% 3) If not empty then do this
\newcommand{\ifNoArgumentElse}[3]{
\ifthenelse{\isempty{#1}}{#2}{#3}%
}
\newcommand{\cross}[1][1pt]{\ooalign{%
\rule[1ex]{1ex}{#1}\cr% Horizontal bar
\hss\rule{#1}{.7em}\hss\cr}% Vertical bar
}
\begin{document}
\subsection{Else Jensen}
\label{person1}
\createPerson
{\nameref{person1}}
{Else Nielsen}
{Else}
{11}
{9}
{1940}
{13}
{11}
{1999}
\subsection{Hans Wright}
\label{person2}
\createPerson
{\nameref{person2}}
{}
{Hans}
{11}
{9}
{1940}
{}
{11}
{1999}
\end{document}