# Tabularx inside tabularx in a scrartcl class based document

I am using a template which uses a scrartcl based class. In this class I have two commands (\part and \personal) both using tabularx. I am trying to put as the second argument of \part, the box generated with the command \personal.

Putting the command as an argument is giving an error and also, when I added tabularx to the command \part, the text is no longer centered even though I specified \begin{center}.

Here is the class with all the commands:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{tccv}
[2012/11/09 v1.0
Two Column Curriculum Vitae]

\setcounter{secnumdepth}{-1}
\RequirePackage[hmargin=1.25cm,vmargin=1.25cm,twocolumn,columnsep=1.25cm]{geometry}
\RequirePackage{bookman,etoolbox,hyperref,needspace,tabularx,xcolor,fontawesome}

% Capitalize words of at least a minimum length (default to 3 chars).
% The text is capitalized before being expanded.
%
% This macro uses Lua to do the job but fails gracefully (that is,
% return the text as is) if \directlua is not available.
%
% |[
% \ucwords[optional: miminum length]{text}
% ]|
\newcommand\ucwords[2][3]{%
% Fails gracefully if not in LuaLaTeX
\providecommand\directlua[1]{#2}%
\directlua{%
local minlen=tonumber("#1")
local src="\luaescapestring{\unexpanded{#2}}"
local dst={}
for w in src:gmatch('[^\string\%s]+') do
if w:len() >= minlen then w = w:sub(1,1):upper()..w:sub(2) end
table.insert(dst, w)
end
tex.print(dst)}}

\pagestyle{empty}
\setlength\parindent{0pt}
\color[HTML]{303030} % Default foreground color
\setkomafont{disposition}{\color[HTML]{0058B6}}
\setkomafont{section}{\scshape\Large\mdseries}

% In tccv \part must contain the subject of the curriculum vitae.
% The command will start a new page and output in onecolumn the
% subject (first and last name) with the hardcoded text
% "Curriculum vitae" under it.
\renewcommand\part[2]{%
\twocolumn[%
\begin{center}
\vskip-\lastskip%
\begin{tabularx}{\linewidth}{ r | l }
{\usekomafont{part} #1} & {#2} %\medskip\\
%{\fontfamily{pzc}\selectfont\Huge Curriculum vitae}
\end{tabularx}
\bigskip
\end{center}]}

% Overrides the \section command to capitalize every
% word for cosmetic purposes and draws a rule under it.
\makeatletter
\let\old@section\section
\renewcommand\section[2][]{%
\old@section[#1]{\ucwords{#2}}%
\newdimen\raising%
\raising=\dimexpr-0.7\baselineskip\relax%
\vskip\raising\hrule height 0.4pt\vskip-\raising}
\makeatother

% Allow conditionals based on the job name. This can usually be set
% from a command-line argument: check fausto.en.tex for an example.
%
% |[
% \ifjob{jobname}{content if matches}{content if does not match}
% ]|
\newcommand\ifjob[3]{%
\edef\JOBNAME{\jobname}%
\edef\PIVOT{\detokenize{#1}}%
\ifdefstrequal{\JOBNAME}{\PIVOT}{#2}{#3}%
}

% Renders a personal data box:
%
% |[
% \personal[optional: web site without scheme (no http:// prefix)]
% ]|
\newcommand\personal[4][]{%
\needspace{0.5\textheight}%
\newdimen\boxwidth%
\boxwidth=\dimexpr\linewidth-2\fboxsep\relax%
\colorbox[HTML]{C7E2F2}{%
\begin{tabularx}{\boxwidth}{c|X}
\faMapMarker  & {#2}\smallskip\\
\faPhone     & {#3}\smallskip\\
\faEnvelope      & \href{mailto:#4}{#4}
\end{tabularx}}}

% Use only \item inside this environment: no other macros
% are allowed:
%
% |[
% \item{fact}{description}
% ]|
\newenvironment{factlist}{%
\newdimen\unbaseline
\unbaseline=\dimexpr-\baselinestretch\baselineskip\relax
\renewcommand\item[2]{%
\textsc{##1} & {\raggedright ##2\medskip\\}\\[\unbaseline]}
\tabularx{\linewidth}{rX}}
{\endtabularx}

%% End of file tccv.cls'.


And this is the latex document:

\documentclass{tccv}
\usepackage[english]{babel}
\usepackage{fontawesome}
\usepackage[gen]{eurosym}

\begin{document}

\part{Name}{\personal
{+33 654 32 10 98}
{someone@gmail.com}}

\section{Languages}

\begin{factlist}
\item{Spanish}{Native speaker}
\item{English}{Level C2 }
\item{French}{Level C1 }
\end{factlist}

\section{Software skills}

Python $\bullet$ Java $\bullet$ JavaScript $\bullet$ Matlab $\bullet$ Android Studio $\bullet$ Microsoft Office $\bullet$ C $\bullet$ \LaTeX $\bullet$ Solid Edge $\bullet$ Altium $\bullet$ Arduino

\end{document}


So basically I would like to have the blue box replacing Here is where the box should go, as shown in image. Thanks in advance for your suggestions!

EDIT: I have cleaned the code. When speaking of having the command \part centered, I mean that the Name is centered in the page (normally the layout is two-column so I would like only the Name|Box to be in the center of the page.

EDIT 2: I have change the latex document with what I wanted to achieve and gave me an error.

• Can you remove the code which is not relevant to your question? What is the text of the error you get? Note that a tabularx requires at least one X-type column, that hyperref should be loaded late and that you need to box the stuff you put in the argument of \twocolumn, probably. – cfr Jun 19 '17 at 1:47
• Don't use \makeatletter or \makeatother in a class or package file. And don't use \\  to break lines outside tabulars etc. – cfr Jun 19 '17 at 1:50
• I have removed unnecessary code, why shouldn't I use \makeatletter and \makeatother in a class? Thanks in advance. – Juan Castillo Jun 19 '17 at 7:04
• Well, @ is already a letter. When you say \makeatother you are setting the catcodes to something which is not standard for class and package files. That is, LaTeX expects (and other things you load expect) that @ is other here. So \makeatletter is pointless and \makeatother is wrong. – cfr Jun 19 '17 at 12:51

It isn't clear what you want centred.

Here are two much minimised versions.

\begin{filecontents}{tccv.cls}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{tccv} [2012/11/09 v1.0 Two Column Curriculum Vitae]

\RequirePackage[hmargin=1.25cm,vmargin=1.25cm,twocolumn,columnsep=1.25cm]{geometry}
\RequirePackage{array,tabularx}

\pagestyle{empty}
\setlength\parindent{0pt}

\renewcommand\part[2]{%
\twocolumn[%
\begin{center}
\vskip-\lastskip%
\begin{tabularx}{\linewidth}{ r | >{\centering\arraybackslash}X }
{\usekomafont{part} #1} & {#2}
\end{tabularx}
\bigskip
\end{center}]}

\endinput
\end{filecontents}

\documentclass{tccv}

\begin{document}

\part{Name}{Here is where the box should go}

\end{document}


Note that all the center environment does here is add vertical space, since the tabular is \linewidth wide, so takes the whole line.

If you don't want that, you might want

\renewcommand\part[2]{%
\twocolumn[%
\vskip-\lastskip%
\begin{tabularx}{\linewidth}{ X | X }
{\usekomafont{part} \hfill #1} & {#2}
\end{tabularx}
\bigskip]}


More likely, you want neither version, but something more like the following.

\renewcommand\part[2]{%
\twocolumn[%
\vskip-\lastskip
{\usekomafont{part}\hfill #1 \textbar\ }#2\hfill\bigskip\par]}
`
• Many thanks for your suggestions, when I get back home I will try your solutions. Have you managed to replace the second argument with the box or it gives you an error? – Juan Castillo Jun 19 '17 at 7:06
• @JuanCastillo No. I didn't understand your question well enough to figure out which box you meant and I didn't have an error message to provide a clue, either, so I just focussed on the centring bit. I didn't understand that either, but I could generate a number of possible interpretations. – cfr Jun 19 '17 at 12:54
• Sorry if it wasn't clear, I will update the post with the errors I get when I get back home. As for the centering part, the last solution is the one I was looking for. I have changed the code to show the error I am getting. Thanks again for your help. – Juan Castillo Jun 19 '17 at 13:52
• I have tried your second suggestion and it even fixes the other issue! Thanks! – Juan Castillo Jun 19 '17 at 19:11
• @JuanCastillo Stroke of luck, I guess, since I certainly didn't design it to do what I didn't understand at the time :-). – cfr Jun 19 '17 at 22:24