1

I'm using scrlttr2 class for work related letters. I'm trying to create a template that I can use for different standard letters.

So for example one of the things I've done is create a client name command that will feed into the body of the letter.

What this question is about is how can I create a system where I can have options for paragraphs.

Example would be I have a command that is client type and options would be audit, exempt, and nonincorp. In the body of the letter we would have paragraph A (audit), B (exempt) & C (nonincorp), so depending on what option was chosen the letter would print the correct one and hide the other two.

I'm thinking something like \entity{audit} in the preamble would trigger the needed paragraphs.

Based on @cfr comment I made a stab at a MWE; it compiles but it doesn't work, but I hope it gives an idea of what I want to do.

\documentclass[parskip, a4paper]{scrlttr2}

%%% Letter Variables:
\newcommand*\ClientName{XYZ Limited}
\newcommand*\EnityType{Audit}
\newcommand*\Payroll{Yes}


%%% Subject line (optional)
\setkomavar{subject}{RE: Letter of Engagement for \ClientName.}

%%% Reference variables
%\setkomavar{yourref}{}
\setkomavar{myref}{Letter ref xyz}

\begin{document}
    \begin{letter}{%
            The Directors\\
            \ClientName\\
            Main Street\\
            Some Town           
        }
    \opening{Dear Directors,}

    \ifx\EnityType\Audit%
    This is text for audit % Audit
    \else% 
    \ifx\EnityType\NonAudit%
    this is text for non audit % Non Audit
    \else% 
    \ifx\EnityType\NonIncorp% 
    this is text for non incorporated entity % NonIncorp
    \fi%
    \fi% 

    \ifx\Payroll\Yes%
    We provide Payroll Services % Yes
    \else% 
    We don't provide payroll services % No
    \fi%




    \closing{Yours faithfully,}


    %\encl{Attachment 1}
    %\cc{someone else 1\\ someone else 2}

\end{letter}
\end{document}
2
  • 1
    Why can't you provide an MWE with what you've got? Why expect people to start from scratch? You already said you have stuff done: the fact that you don't know how to do this particular bit doesn't mean you can't provide an MWE. Also, you have provided no sense of the input and output you want. You want \entity{<type>} in the preamble, but what will the body look like and what difference does this make? Do you just want to toggle setting or not setting bits of a document? Or is the 'type' of paragraphs actually relevant to your needs? Lots of ways to do the former; the latter is very unclear.
    – cfr
    Commented Jul 7, 2018 at 0:13
  • @cfr I've had an extra think about how I want this to work and have made an attempt at an MWE. Hopefully it adds some clarity, but feel free to ask if anything else is unclear.
    – gman
    Commented Jul 7, 2018 at 12:20

1 Answer 1

3

Generally this is a document with conditional compiling. Your document already would compile, if you would define \Audit, \NonAudit, \NonIncorp and \Yes. However, I think some changes in the logic would be useful. And, indeed, instead of the packages given in the link above, there is also a KOMA-Script solution, using KOMA-Script command \ifstr (see the manual for more information):

\documentclass[parskip]{scrlttr2}

%%% Letter Variables:
\newcommand*\EntityType{Audit}
% \newcommand*\EntityType{Incorp}
% \newcommand*\EntityType{Other}
\newcommand*\Payroll{Yes}
% \newcommand*\Payroll{No}

\newkomavar[Client name]{ClientName}
\setkomavar{ClientName}{XYZ Limited}

%%% Subject line (optional)
\setkomavar{subject}{RE: Letter of Engagement for \usekomavar{ClientName}.}

%%% Reference variables
%\setkomavar{yourref}{}
\setkomavar{myref}{Letter ref xyz}

\begin{document}
    \begin{letter}{%
            The Directors\\
            \usekomavar{ClientName}\\
            Main Street\\
            Some Town           
        }
    \opening{Dear Directors,}

    \ifstr{\EntityType}{Audit}{% Audit
      This is text for audit%
    }{%
      This is text for non audit% Non Audit
      \ifstr{\EntityType}{Incorp}{}{% and Non Incorp
        \ and for non incorporated entity%
      }%
    }.

    We
    \ifstr{\Payroll}{Yes}{}{don't }%
    provide payroll services.

    \closing{Yours faithfully,}
\end{letter}
\end{document}

result with \EntityType=Audit and \Payroll=Yes

Try also the given alternative settings of \EntityType and \Payrole they would, e.g., result in:

result with \EntityType=Incorp and \Payroll=No

result with \EntityType=Other and \Payroll=No

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .