2

I'm trying to construct a form letter, using information stored in a file "data.dat". It all works, but I am having trouble finding a solution to discriminate between he/she or him/her, depending on the gender of the subject. I presume it would be a conditional, but how it would look, I have no clue. My MWE (at the moment) is:

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{textmerg}
\usepackage[margin=0.75in]{geometry}
\pagenumbering{gobble}
\begin{document}

\Fields{\Mr\Dad\DSurName\Ms\Mum\MSurname\Address\StudentFirst\StudentLast}


\Merge{STEMdata.dat}{
\hspace{.25\textwidth}
\begin{flushright}
\bf \Mr\ \Dad\ \DSurName\ \& \Ms\ \Mum\ \MSurname\\
\bf\Address
\end{flushright}
\vspace{2 cm}
\begin{flushright}
\today
\end{flushright}
 \begin{center}
   \textsc{ADVICE OF PROGRESS\\
    COURSE:} 
\end{center}

Dear \Mr\ \DSurName,\par
\StudentFirst\,\StudentLast: \par

This matter has been discussed with \StudentFirst\ and \heshe understands     what is expected in iSTEM in the future.\\
\vfill
\begin{flushright}
\rule{6cm}{0.025cm}\\
Joe Bloggs
\end{flushright}
\newpage
}
\end{document} 

I have looked at datatool and ifthen, but no luck on where I would replace \heshe in the code.

Thanks in advance for any suggestions.

1

You can add an \ifx within the merge block. Several other options for conditionals exist, but in this case the built-in seems to work ok. MWE:

\documentclass{article}
\usepackage{textmerg}
\begin{document}

\def\he{male}
\def\she{female}

\Fields{\SurName\StudentFirst\gender}

\Merge{STEMdatashort.dat}{
\ifx\gender\he
    \def\heshe{he}
\else
    \def\heshe{she}
\fi
Dear Mr. \SurName,\par

The grade of \StudentFirst\ has been discussed and \heshe\ understands what is expected in iSTEM in the future.\\

Joe Bloggs
\newpage
}
\end{document} 

STEMdatashort.dat:

Smith
Jenny
female
Brown
Josh
male

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.