2

I am using the multiaudience package to create two different versions of a LaTeX document. My document contains a tabular environment with a table row which I want to make visible to one audience only. Is there a way of doing this?

The two approaches I've used below (the lines I've commented out for now) each cause errors, because the & and the \\ are enclosed in the text to be shown to the audience. I can of course use showto's or shownto's to enclose just the text within individual table cells but this still creates a table row (i.e., any text not visible for the current audience results in a blank line in the table).

\documentclass{article}

\usepackage{multiaudience}
\SetNewAudience{a1}
\SetNewAudience{a2}
\DefCurrentAudience{a2}

\begin{document}

\begin{tabular}{ll}
Thing1 & Thing2\\
\hline
This thing & To be seen by everyone\\
%\showto{a1}{That thing & To be seen by a1 only\\}
%\begin{shownto}{a2}Other thing & To be seen by a2 only\\\end{shownto}
Final thing & Everyone can see this too
\end{tabular}

\end{document}

Is there

  1. some way round this using multiaudience
  2. an alternative package which will do this for me?
1

You can do so by moving the logic of that all into an \omit...\cr block. The following does so. It always starts a new row after \tableshowto regardless of whether you used \\ or not. The environment variant still doesn't work with this.

And before I forget, it must be used as the first thing in a cell, but it will start a new row for its argument and after it, so it is only really meant to work on a complete row.

\documentclass{article}

\usepackage{multiaudience}
\SetNewAudience{a1}
\SetNewAudience{a2}
%\DefCurrentAudience{a2}
\DefCurrentAudience{a1}

\makeatletter
\long\def\@afterfi#1\fi{\fi#1}
\newcommand\tableshowto[2]
  {%
    \omit
    \@MULTAU@shownfalse
    \@MULTAU@includetrue
    \setkeys{MULTAU}{#1}%
    \if@MULTAU@shown
      \@afterfi{\cr#2\crcr\omit}%
    \fi
    \@MULTAU@showntrue
    \@MULTAU@includetrue
    \cr
  }
\makeatother

\begin{document}

\begin{tabular}{ll}
Thing1 & Thing2\\
\hline
This thing & To be seen by everyone\\
\tableshowto{a1}{That thing & To be seen by a1 only\\}
Final thing & Everyone can see this too
\end{tabular}

\end{document}

Output for a1:

a1

Output for a2:

a2

| improve this answer | |

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.