2

I had previously used the multiaudience package without any problem. But now I have a document with multiple audiences and I need to get the result for two audiences at once. I have 5 audiences, grouped into 2 types of audiences with slight variations. On the one hand there is the type "a,b,c" and on the other the type "x,y". My intention is to define the value "a,x" as the current audience and get the result for both "a" and "x" audiences.

I know I could define the audiences by making all the possible combinations, something like this:

\SetNewAudience{ax}
\SetNewAudience{ay}
\SetNewAudience{bx}
\SetNewAudience{by}
\SetNewAudience{cx}
\SetNewAudience{cy}

But I don't want to do this, I prefer to define the audiences as normal and get the result for two of them.

This is my code as far as I can get to. I've redefined the command \SetNewAudience, but it doesn't work.

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage{multiaudience}
\usepackage{xkvview}
\usepackage{xparse}

%Command provided by user31729 from: https://tex.stackexchange.com/questions/287084/membership-check-on-comma-separated-list/287085?r=SearchResults#287085
\ExplSyntaxOn
\NewDocumentCommand{\IsMember}{mm+m+m}{%
\clist_set:Nx \l_tmpa_clist {#1}
\clist_if_in:NnTF \l_tmpa_clist {#2} {#3} {#4}
}
\ExplSyntaxOff

\makeatletter
\def\showWhenAppropriate{%
  \if@MULTAU@include%
    \@MULTAU@showntrue%
  \else%
    \@MULTAU@shownfalse%
  \fi%
}
\def\SetNewAudience#1{%
  \define@key{MULTAU}{#1}[]{%
    \def\@MULTAU@currkey{#1}%
    \IsMember{\CurrentAudience}{\@MULTAU@currkey}{\showWhenAppropriate}{\relax}
  }%
}
\makeatother

\DefCurrentAudience{a,x}

\SetNewAudience{a}
\SetNewAudience{b}
\SetNewAudience{c}
\SetNewAudience{x}
\SetNewAudience{y}

\begin{document}

Current audience: \CurrentAudience % for testing

\xkvview{} % for testing

\showto{a}{a}

\showto{b}{b}

\showto{c}{c}

\showto{x}{x}

\showto{y}{y}

\showto{a,x}{ax}

\showto{-,a,x}{bcy}

\end{document}

Thanks in advance.

2 Answers 2

1

I submitted a new version for CTAN which solves this problem.

Here is the new code. You do not need to use this if your version is 1.05 (soon to be on CTAN) or newer:

\def\SetNewAudience#1{%
  \define@key{MULTAU}{#1}[]{%
    \def\@MULTAU@currkey{#1}%
    \@for\@tempa:=\CurrentAudience \do{%
      \ifx\@MULTAU@currkey\@tempa\relax
        \if@MULTAU@include
           \@MULTAU@showntrue
        \else
           \@MULTAU@shownfalse
        \fi%
    \fi%
}}}

Example: \DefCurrentAudience{ax,ay,az} (note the absence of spaces between the audiences).

0

I just had the same problem and it looks like the multiaudience package can't do that, unfortunately.

I used the optional package instead:

\documentclass{minimal}

\usepackage[foo,bar]{optional}

\begin{document}

\opt{foo}{foo}

\opt{bar}{bar}

\opt{foo,bar}{foobar}

\end{document}
1
  • Well, looks like I need to add this functionality to the package...
    – Boris
    Oct 2, 2021 at 17:26

You must log in to answer this question.

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