2

I've written notes for my students and I want to create different versions of them: a short one, to print, and a long one, to distribute them through internet. So for the same content, and I want to compile it twice with different behaviour.

Here is a MWE of what I do:

  • the content of chapter 1 is content1.tex
\begin{document}

This is some text.

\important{This is very important.}

\remark{This is a remark.}

\end{document}
  • the content of chapter 2 is content2.tex
\begin{document}

\important{This is very very very important.}

\remark{This is a useless remark.}

This is some text

\end{document}
  • the file full_version.tex contains a first set of \newcommands:
\documentclass{standalone}

\newcommand{\important}[1]{\textbf{#1}}
\newcommand{\remark}[1]{\textit{Remark: #1}}
  • the file short_version.tex contains a second set of \newcommands:
\documentclass{standalone}

\newcommand{\important}[1]{\textbf{#1}}
\newcommand{\remark}[1]{}

My solution is the following: to compile the content1 with the full_version preamble, I write this command on Linux shell:

 cat full_version.tex content1.tex | latex

It works, but is not very satisfactory (many strange messages); and Linux-shell dependant.

Are there better way to achieve this? Perhaps with precompiled preambles?

  • you don't need to use cat just put \input{content} into your two top level files. – David Carlisle Jul 11 '16 at 6:55
  • Okay, but my top level files will be used for many contents, since my notes are divided in many chapters. So I need a method that can combine any top level file with any content file. – JPG Jul 11 '16 at 7:01
  • I modified the question to make it clearer. – JPG Jul 11 '16 at 7:09
  • you can compile with latex \input{full_version.tex}\input{content1.tex} – touhami Jul 11 '16 at 7:40
  • 1
    You could try with multiaudience package. This is an example: tex.stackexchange.com/a/266682/1952 – Ignasi Jul 11 '16 at 8:33
1

You can compile using something like:

latex -jobname="full_chapter1" "\input{full_version}\input{chapter1}"
  • Exactly what I wanted, and good hint the jobname to rename output. – JPG Jul 11 '16 at 9:54

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.