Always making my lessons, i've defined some commands to separate teacher
and student
stuff. The structure is the same than what is described on this post. A MWE is at the end.
At the moment, i've to compile one time, changing the name of the output, changing the file.tex
to set the second version, recompile and rename this second output.
I want to make my life better by changing the pdflatex
compilation command in texstudio
to compile twice and changing automatically the version
and the corresponding output.
I've read it's possible in the command line of Texstudio
and i've read it's also possible with a bash file on this post. To be honest, i can't write/use/understand a bash so i prefer the first way.
How can i achieve :
- Compiling my
foo.tex
first with the option\setversion{student}
and rename it asfoo_student.tex
- Compiling second time (in the same run) my
foo.tex
with the option\setversion{teacher}
and rename it asfoo_teacher.tex
What I've done so far is to compile twice and create two pdf with different name but no differences on the contents with the following command :
pdflatex -synctex=1 -interaction=nonstopmode -jobname=%_student main.tex | pdflatex -synctex=1 -interaction=nonstopmode -jobname=%_teacher main.tex
Here is a MWE for main.tex
\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{etoolbox}
\newbool{studentversion}
\setbool{studentversion}{false}
\newcommand\setversion[1]{%
\def\tempa{#1}%
\def\tempb{student}%
\ifx\tempa\tempb
\setbool{studentversion}{true}%
\else
\def\tempb{teacher}%
\ifx\tempa\tempb
\setbool{studentversion}{false}%
\else
\errmessage{Unknown value for studentversion: #1}%
\fi
\fi
}
\newcommand{\ProfDifference}[2]%
{%
\ifbool{studentversion}%
{%%True (student version)
#1
}%
{%%False (teacher version)
#2
}
}
\setversion{teacher} %%Modify this line to change the version
\begin{document}
The following text depends of the version :
\ProfDifference{It's the student version.}{It's the teacher version.}
\end{document}