I am composing some notes for a workshop which will have a mixed audience who use different statistical software packages. For the lab sessions, I wish to create a practice that contains questions and corresponding software codes.
My question: could anyone kindly recommend what are some methods to allow for switching some software code on/off so that I can i) just write the question once, and ii) compile different versions for different users?
Here is the scheme:
And I put the codes at the end as a minimal replicable example.
Ideally, it'd be great if I can incorporate a command (macro?) such as:
printSoftwareA
% printSoftwareB
% printSoftwareC
at the preamble so that I can switch them on or off. The reason I'd like to see them all in one document is that it'd be easier for me to main all the codes at once to ensure coherence between the software.
\documentclass[12pt]{article}
\usepackage{xcolor}
\usepackage{listings}
\definecolor{verbgray}{gray}{0.9}
\lstnewenvironment{code}{%
\lstset{backgroundcolor=\color{verbgray},
frame=single,
framerule=0pt,
basicstyle=\ttfamily,
columns=fullflexible}}{}
\begin{document}
\section*{General text for all readers}
This is the text I'd like to show all readers.
\subsection*{How to do it in Software A}
\begin{code}
proc reg;
model y=x;
run;
\end{code}
\subsection*{How to do it in Software B}
\begin{code}
reg y x
\end{code}
\end{document}