Hi i've been trying to fill a 2 column table using a \foreach loop and inside i use a conditional to see if i do a line break or not:
\newcommand\skillstext[1]{
\renewcommand{\skillstext}{
\begin{tabular}{cc}
\foreach [count=\i] \x in {#1}{
\ifthenelse{\ifodd\value{\i}{true}}{\x \\}{\x &}
}
\end{tabular}
}
}
however this wont work also i dont know if its important but in the error message it says its too big for \hbox, i ghuess its because it is in a sidebar that i created
UPDATE: example code Hi so this is what i'm trying to make work:
Here is the .tex code
\documentclass[letterpaper]{cvdocex} % a4paper for A4
%----------------------------------------------------------------------------------------
% PERSONAL INFORMATION
%----------------------------------------------------------------------------------------
% If you don't need one or more of the below, just remove the content leaving the command, e.g. \cvnumberphone{}
\cvname{Name} % Your name
\cvjobtitle{thing} % Job title/career
\stident{st}
\cvdate{\today} % Date of birth
\cvaddress{england} % Short address/location, use \newline if more than 1 line is required
\cvnumberphone{999 999 9999} % Phone number
\cvsite{}
\cvmail{} % Email address
%----------------------------------------------------------------------------------------
\begin{document}
%----------------------------------------------------------------------------------------
% Creation de side bar
%----------------------------------------------------------------------------------------
%----------------------------------------------------------------------------------------
% À propos de moi
%----------------------------------------------------------------------------------------
\aboutme{}
%----------------------------------------------------------------------------------------
% SKILLS
%----------------------------------------------------------------------------------------
% Skill definitions
% Skill bar section, each skill must have a value between 0 an 6 (float)
\skills{{Relations Public/4},{MATLAB/5},{CATIA V5/5},{VBA/5.5}}
%------------------------------------------------
% Skill text section
\skillstext{{LaTeX},{SQL},{Suite MS Office},{Leadership},{cohésion d'équipe},{C++}}
%----------------------------------------------------------------------------------------
\makeprofile % Print the sidebar
\end{document}
and here is the .cls code (where the skillstext command is):
\ProvidesClass{cvdocex}[2015/02/28 CV class]
\LoadClass{article}
\NeedsTeXFormat{LaTeX2e}
%----------------------------------------------------------------------------------------
% REQUIRED PACKAGES
%----------------------------------------------------------------------------------------
\RequirePackage[sfdefault]{ClearSans}
\RequirePackage[T1]{fontenc}
\RequirePackage{tikz}
\RequirePackage{fontawesome}
\RequirePackage{xcolor}
\RequirePackage[absolute,overlay]{textpos}
\RequirePackage{enumitem}
\RequirePackage{ragged2e}
\RequirePackage{etoolbox}
\RequirePackage{ifmtarg}
\RequirePackage{ifthen}
\RequirePackage{pgffor}
\RequirePackage{marvosym}
\RequirePackage{parskip}
\RequirePackage{hyperref}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions\relax
%----------------------------------------------------------------------------------------
% COLOURS
%----------------------------------------------------------------------------------------
\definecolor{white}{RGB}{255,255,255}
\definecolor{gray}{HTML}{4D4D4D}
\definecolor{sidecolor}{HTML}{E7E7E7}
\definecolor{mainblue}{HTML}{377933} %actually green
\definecolor{maingray}{HTML}{B9B9B9}
%----------------------------------------------------------------------------------------
% MISC CONFIGURATIONS
%----------------------------------------------------------------------------------------
\renewcommand{\bfseries}{\color{gray}} % Make \textbf produce coloured text instead
\pagestyle{empty} % Disable headers and footers
\setlength{\parindent}{0pt} % Disable paragraph indentation
%----------------------------------------------------------------------------------------
% SIDEBAR DEFINITIONS
%----------------------------------------------------------------------------------------
\setlength{\TPHorizModule}{1cm} % Left margin
\setlength{\TPVertModule}{1cm} % Top margin
\newlength\imagewidth
\newlength\imagescale
\pgfmathsetlength{\imagewidth}{5cm}
\pgfmathsetlength{\imagescale}{\imagewidth/600}
\newcommand{\profilesection}[2]{\vspace{8pt}{\color{black!80} \huge #1 \rule[0.15\baselineskip]{#2}{1pt}}}
% Define custom commands for CV info
\newcommand{\stident}[1]{\renewcommand{\stident}{#1}}
\newcommand{\cvdate}[1]{\renewcommand{\cvdate}{#1}}
\newcommand{\cvmail}[1]{\renewcommand{\cvmail}{#1}}
\newcommand{\cvnumberphone}[1]{\renewcommand{\cvnumberphone}{#1}}
\newcommand{\cvaddress}[1]{\renewcommand{\cvaddress}{#1}}
\newcommand{\cvsite}[1]{\renewcommand{\cvsite}{#1}}
\newcommand{\aboutme}[1]{\renewcommand{\aboutme}{#1}}
\newcommand{\profilepic}[1]{\renewcommand{\profilepic}{#1}}
\newcommand{\cvname}[1]{\renewcommand{\cvname}{#1}}
\newcommand{\cvjobtitle}[1]{\renewcommand{\cvjobtitle}{#1}}
% Command for printing the contact information icons
\newcommand*\icon[1]{\tikz[baseline=(char.base)]{\node[shape=circle,draw,inner sep=1pt, fill=mainblue,mainblue,text=white] (char) {#1};}}
% Command for printing skill progress bars
\newcommand\skills[1]{
\renewcommand{\skills}{
\begin{tikzpicture}
\foreach [count=\i] \x/\y in {#1}{
\draw[fill=maingray,maingray] (0,\i) rectangle (6,\i+0.4);
\draw[fill=white,mainblue](0,\i) rectangle (\y,\i+0.4);
\node [above right] at (0,\i+0.4) {\x};
}
\end{tikzpicture}
}
}
% Command for printing skills text
\newcommand\skillstext[1]{
\renewcommand{\skillstext}{
\begin{tabular}{cc}
\foreach [count=\i] \x in {#1}{
\ifthenelse{\ifodd\value{\i}{true}}{\x \\}{\x &}
}
\end{tabular}
}
}
%----------------------------------------------------------------------------------------
% SIDEBAR LAYOUT
%----------------------------------------------------------------------------------------
\newcommand{\makeprofile}{
\begin{tikzpicture}[remember picture,overlay]
\node [rectangle, fill=sidecolor, anchor=north, minimum width=9cm, minimum height=\paperheight+1cm] (box) at (-5cm,1cm){};
\end{tikzpicture}
%------------------------------------------------
\begin{textblock}{6}(0.5, 0.2)
% %------------------------------------------------
%
% \begin{center}
% \begin{tikzpicture}[x=\imagescale,y=-\imagescale]
% \clip (600/2, 567/2) circle (567/2);
% \node[anchor=north west, inner sep=0pt, outer sep=0pt] at (0,0) {\includegraphics[width=\imagewidth]{\profilepic}};
% \end{tikzpicture}
% \end{center}
%
% %------------------------------------------------
\vspace{5mm}
{\Huge\color{mainblue}\cvname}
%------------------------------------------------
{\Large\color{black!80}\cvjobtitle}
%------------------------------------------------
\renewcommand{\arraystretch}{1.6}
\begin{tabular}{p{0.5cm} @{\hskip 0.5cm}p{5cm}}
\ifthenelse{\equal{\stident}{}}{}{\textsc{\icon{\faGraduationCap}} & \stident\\}
\ifthenelse{\equal{\cvdate}{}}{}{\textsc{\Large\icon{\Info}} & \cvdate\\}
\ifthenelse{\equal{\cvaddress}{}}{}{\textsc{\Large\icon{\Letter}} & \cvaddress\\}
\ifthenelse{\equal{\cvnumberphone}{}}{}{\textsc{\Large\icon{\Telefon}} & \cvnumberphone\\}
\ifthenelse{\equal{\cvsite}{}}{}{\textsc{\Large\icon{\Mundus}} & \href{\cvsite}{\cvsite}\\}
\ifthenelse{\equal{\cvmail}{}}{}{\textsc{\large\icon{\MVAt}} & \href{mailto:\cvmail}{\cvmail}}
\end{tabular}
%------------------------------------------------
\profilesection{About me}{2.6cm}
\begin{justify}
\aboutme
\end{justify}
%------------------------------------------------
\profilesection{Skills}{4cm}
\skills
\skillstext
\scriptsize
(*)[The skill scale is from 0 (Fundamental Awareness) to 6 (Expert).]
%------------------------------------------------
\end{textblock}
}
\RequirePackage[left=7.6cm,top=0.5cm,right=1cm,bottom=0.6cm,nohead,nofoot]{geometry}
Sorry forgot to metion this is a modified version of the twenty second CV template class. Downloaded from here :http://www.latextemplates.com/template/twenty-seconds-resumecv all credits go to the author
\makeprofile
. I don't see the benefit in processing them earlier and storing the result. But perhaps I am missing something. Note that your definitions contain lots of spurious (presumably spurious) spaces and paragraph breaks. – cfr Oct 10 '16 at 1:08