# pandoc: “template” error, unexpected x

When I run make on my Pandoc file, I get the following error.

pandoc: "template" (line 113, column 7):
unexpected "x"
expecting "$endfor$"
make: *** [output.pdf] Error 1


As far as I can tell, everything in the file is correct:

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass[$fontsize$, a4paper]{article}

% LAYOUT
%--------------------------------
% Margins
\usepackage{geometry}
\geometry{$geometry$}

% Do not indent paragraphs
\setlength\parindent{0in}

% Enable multicolumns
\usepackage{multicol}
\setlength{\columnsep}{-3.5cm}

% Uncomment to suppress page numbers
% \pagenumbering{gobble}

% LANGUAGE
%--------------------------------
% Set the main language
$if(lang)$
\usepackage{polyglossia}
\setmainlanguage{$lang$}
$endif$

% TYPOGRAPHY
%--------------------------------
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}
% converts LaTeX specials (quotes, dashes etc.) to Unicode
\defaultfontfeatures{Mapping=tex-text}
\setromanfont [Ligatures={Common}, Numbers={OldStyle}]{$mainfont$}
% Cool ampersand
\newcommand{\amper}{{\fontspec[Scale=.95]{$mainfont$}\selectfont\itshape\&}}

% MARGIN NOTES
%--------------------------------
\usepackage{marginnote}
\newcommand{\note}[1]{\marginnote{\scriptsize #1}}
\renewcommand*{\raggedleftmarginnote}{}
\setlength{\marginparsep}{7pt}
\reversemarginpar

%--------------------------------
\usepackage{sectsty}
\usepackage[normalem]{ulem}
\sectionfont{\rmfamily\mdseries}
\subsectionfont{\rmfamily\mdseries\scshape\normalsize}
\subsubsectionfont{\rmfamily\bfseries\upshape\normalsize}

% PDF SETUP
%--------------------------------
\usepackage{hyperref}
\hypersetup
{
pdfauthor={$name$},
pdfsubject={$name$'s CV},
pdftitle={$name$'s CV},
filecolor=black,
urlcolor=[rgb]{0.117,0.682,0.858},
citecolor=[rgb]{0.117,0.682,0.858}
}

% DOCUMENT
%--------------------------------
\begin{document}

{\LARGE $name$}\\[.2cm]

\begin{multicols}{2}

$for(address)$
$address$\\
$endfor$

\vspace{-10pt}

$phone$\\
\href{mailto:$email$}{$email$}\\

\columnbreak

$for(urls)$
\href{http://$urls$}{$urls$}\\
$endfor$
\end{multicols}

% \vfill

$intro$

\subsection*{Areas of Interest}
\begin{itemize}
$for(skills)$
\item $skills$
$endfor$
\end{itemize}

% \vfill

\section*{Previous Experience}
\noindent
$for(experience)$
\note{$experience.years$}\textsc{$experience.employer$}\\
\emph{$experience.job$}\\
$experience.city$\\[.2cm]
$endfor$

\section*{Education}
\noindent
$for(education)$
\note{$education.year$}\textbf{$education.subject$}$if(education.degree)$, $education.degree$$endif\\ \emph{education.institute}if(education.city), education.city$$endif$\\[.2cm]
$endfor$

$if(languages)$
\section*{Languages}
$for(languages)$
\emph{$languages.language$} ($languages.proficiency$)\\
$endfor$
$endif$

\end{document}

• Thanks for posting a working example! At the same time, much of your code does not seem to be relevant to the question you're asking here. Please limit the example to only the code required for your issue to appear. You can have a look at this guide for how to prune your code for this purpose. – Arun Debray Nov 19 '15 at 4:50
• Maybe your pandoc input is faulty and not the template. – DG' Nov 22 '15 at 11:46
• In my case a similar but slightly different error was caused by conflicting versions of one of pandoc templates. I've been able to solve it simply by removing the old pandoc directory. – Pavel Rudnev Feb 2 '16 at 15:14