3

I'm a teacher and using PdfTeX to write my courses. My question is the following : How can I compile my .teX file and generate into Pdf file : the course itself, and one or two excerpts (that I've chosen) of this same document. Typically, I edit the whole course with annotations for myself throughout the whole document but I want to provide my students with portions of it only (AND without annotations) Thank you

Addendum post comments: Let me a little be more specific : Let's assume a document such as :

\begin{document}

    \begin{tabular}
        Big array
    \end{tabular}

\begin{note for self}
  here should be done ex 2 p75
\end{note for self}

bla bla bla
\end{document}

Then compilation. Nature of the wanted outputs (.pdf) :

1) Normal (with everything provided in the document) for my personal use.

2) The same document WITHOUT the "note for self". For students use.

3) If possible a third output with the array only. For other students to cut out and stick in their notebook. (in the code i used no made up code because I didn't know how to make a reference to it).

I hope my case is a little bit clearer now.

5

multiaudience package could be an alternative to comment package. You will also need several compilations to get any pdf version unless you hide them inside a makefile or any other script system. But multiaudience provides advantatges in front of comment because you can combine/discard different audiences and not only select one of them.

Following you have a little example.

\documentclass{article}
\usepackage{multiaudience}

% Declare all possible audience groups
\SetNewAudience{teachers}
\SetNewAudience{students}
\SetNewAudience{public}

%You can decide the desired audience inside the document
%\DefCurrentAudience{public}

\begin{document}

% this array is always included
\begin{tabular}{c}
  All: First sentence seen by all audiences
\end{tabular}

% only for teachers
\begin{shownto}{teachers}
  Teachers: This text is seen only by teachers
\end{shownto}

% only for teachers and students
\begin{shownto}{public, students}
  Public,students: This text is seen by public and students but not teachers.
  \begin{shownto}{-,students}
  -students: But this one only by public
  \end{shownto}
\end{shownto}

% for all audiences except teachers
\begin{shownto}{-, teachers}
  -teachers: all except teachers.
\end{shownto}

\end{document}

Instead of fixing the audience inside the .tex file you can pass it as a compilation parameter:

pdlatex "\def\CurrentAudience{students}\input{your-tex-file}"
3

This can be done with the comment package like so:

\documentclass{article}
\usepackage{comment}

% Include custom environments before they are included/excluded
\specialcomment{teachersnote}{}{}
\specialcomment{notinsummary}{}{}

% Comment out as needed
\excludecomment{teachersnote}
\excludecomment{notinsummary}

\begin{document}

% this array is always included
\begin{tabular}{c}
  Big array
\end{tabular}

\begin{teachersnote}
  here should be done ex 2 p75
\end{teachersnote}

\begin{notinsummary}
  bla bla bla
\begin{teachersnote}
  this is a note inside a non-summary section.
\end{teachersnote}
\end{notinsummary}
\end{document}

The simplest way to create 3 pdfs in a platform independent way is probably to create 3 different files and use \input to put the body of your document in.


Example:

To compile (to put in a shell script/batch file, or done manually):

pdflatex teachersversion.tex
pdflatex studentsversion.tex
pdflatex studentssummaryversion.tex

preamble.tex:

\documentclass{article}
\usepackage{comment}

% Include custom environments before they are included/excluded
\specialcomment{teachersnote}{}{}
\specialcomment{notinsummary}{}{}

body.tex:

\begin{document}

% this array is always included
\begin{tabular}{c}
  Big array
\end{tabular}

\begin{teachersnote}
  here should be done ex 2 p75
\end{teachersnote}

\begin{notinsummary}
  bla bla bla
\begin{teachersnote}
  this is a note inside a non-summary section.
\end{teachersnote}
\end{notinsummary}
\end{document}

teachersversion.tex:

\input{preamble}

% Comment out as needed
% \excludecomment{teachersnote}
% \excludecomment{notinsummary}

\input{body}

studentsversion.tex:

\input{preamble}

% Comment out as needed
\excludecomment{teachersnote}
% \excludecomment{notinsummary}

\input{body}

studentssummaryversion.tex:

\input{preamble}

% Comment out as needed
\excludecomment{teachersnote}
\excludecomment{notinsummary}

\input{body}
  • @JonathanPotier If you feel one of the answers here is what you're looking for, consider accepting one of them (clicking the faded arrow beneath the voting arrows) – Nathanael Farley Sep 11 '15 at 12:34
2

Some shameless self-promotion: there is also my commenting package, available at

https://github.com/bordaigorl/latex-commenting

You can declare multiple authors

\declareauthor{jon}{Jonathan}{blue}

and put comments in your text with various commands:

\comment[jon]{bla}% Inline comment
\annot[jon]{bla}% Margin comment

and others.

Then you can control what is shown by using either the draft class option or more fine grained macros like

\onlyauthors{jon}

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.