11

I am writing my PhD thesis and as I am not the least chaotic guy I also add notes for future reference. Surely, this means it is not production grade, or how you would like to call it.

There is a nice package called versions which takes care of the versions. We also have the helpful answers in Using latexdiff with git to use git. My goal now is to have something similar to versions but that the content is removed when for example it is in between \advisorcannotsee and \allokay and this would be checked out in the advisorbranch. Preferably, only the main version should be compiled (or the one marked as to be compiled).

Would such a thing already exist, or are there better solutions for this problem?

Per request:

Example workflow:

  1. I have a git repository working on the working directory of my thesis which includes all my remarks using \input or whatever.
  2. I have several branches other than the main branch, say paper1 and advisor which contains the same as the main branch (which contains it all) but then pieces cut out.
  3. I modify my document and I add things which are for my eyes only (main) and some which are for my advisor. I would like to use something like the versions package to mark parts which belong to where.
  4. When done editing I commit my changes. As my modification has parts which belong to a different branch I would like to have that the version which is okay for the advisor gets "built" (pieces cut out) and commited to advisor and the whole thing to main.
JT_NL
  • 2,153
  • 1
    I don't quite understand what you are asking. Could you perhaps elaborate on how you see this workflow working so that we can see more clearly what you mean? – Seamus Oct 08 '12 at 16:25
  • Thanks. I have added a possible workflow! I hope it makes more sense now. – JT_NL Oct 08 '12 at 16:49
  • 2
    Experience suggests that mixing version control (with git) and edition control (with versions, todonotes, and suchlike) can lead one into considerable difficulties (if for exxample you try to control editions through the git branch mechanism). I'm sorry; I'm away from home and my workbench, so I can't write you a fuller answer this week, but I'll have a go at it when I get back. There are good, and simpler (IMO) solutions. – Brent.Longborough Oct 08 '12 at 17:05
  • @Brent.Longborough I am looking forward to it :-). – JT_NL Oct 08 '12 at 17:08
  • As far as I can see, your question can be entirely solved by a moderately advanced usage of git (branches, cloned repo, etc.), so I'd suggest you to ask that question on StackOverflow. – Olivier Oct 08 '12 at 19:17
  • Not sure I understand, but perhaps you can set \advisorcannotsee to disable all the macro that you don't want to produce any output, and \allokay to re-enable the macros? That is pretty easy to do in LaTeX. – Peter Grill Oct 09 '12 at 07:48
  • I don't quite understand the role that git needs to play in all this. What can't you achieve with simple conditionals? – Seamus Oct 09 '12 at 08:17
  • @Seamus The fact that simple conditions are fine to compile different versions, but I not only want simple conditions, I also want the content removed when it is put in another branch. The .tex should not contain the stuff which does not satisfy the conditional. Those different ones could be put in another branch. – JT_NL Oct 09 '12 at 12:49
  • Perhaps, as I use emacs anyway, Org-mode is the way to go... – JT_NL Oct 09 '12 at 13:02
  • If the conditional makes it such that it doesn't get set in the output, why does it matter whether it's in the tex file? Maintaining importantly several different versions of the same document is a recipe for merge-nightmares and disappearing text. I can't see what the use case is for wanting to put yourself through that… – Seamus Oct 09 '12 at 13:22
  • 1
    The idea is that I only modify the main file and the generated files do not have the goal to be merged (otherwise I could use latexdiff if I really wanted to), but more to send to people so they can start working on it. More like a fork. Most mathematicians do not use git. – JT_NL Oct 09 '12 at 14:29

1 Answers1

13

To begin, a couple of definitions:

Revision: One particular state of the files in a project, positioned along one or more lines of history

Edition: One particular variation which has a purpose in being different from other variations

(Notice that I have avided using the word "version"; it's too ambiguous, and will only occur here, if at all, in talking about "version control systems".)

I believe, strongly, that using different Revisions (probably on different branches of a VCS) is not a good way to manage Editions. Personal, embarrassing experience suggests that when branches are created that are not meant ever to merge back together, changes on one branch can get forgotten, or included by mistake, when a change needs to be incorporated in multiple editions.

A far better method is to create a configurable master file, and to include it from a series of top-level files, one for each Edition that is required.

Here is an example with three Editions. It is a very simple exam paper which includes questions, answers, and notes, and uses Viktor Eijkhout's comment package and Hendrik Mittby's todonotes package. You may find other packages more useful for your particular case.

To keep it simple, I haven't used any exam- or Q&A-related packages, just Enrico Gregorio's kantlipsum to pad it out a bit. Please bear in mind that this isn't meant to be an example of "Great Typography", just an illustration of general principles for making polymorphic editions.

The three editions are:

  1. The student edition: questions only
  2. The examiner edition: questions and guidelines for answers
  3. The supervisor edition: questions, guidelines for answers, and my notes to discuss the development of the exam with my supervisor.

The example consists of five TeX files:

Student.tex:

\documentclass[disable]{memoir} % [disable] is passed to todonotes
\input{preamble}
\excludecomment{answers}
\input{master}

Examiner.tex:

\documentclass[disable]{memoir}
\input{preamble}
\includecomment{answers}
\input{master}

Supervisor.tex:

\documentclass{memoir}
\input{preamble}
\includecomment{answers}
\input{master}

preamble.tex:

\usepackage{kantlipsum}
\usepackage{comment}
\usepackage{todonotes}
\newcommand{\mynote}[1]{\todo[inline]{#1}}

master.tex:

\begin{document}
\section{Philosophy}

Compare and contrast Aristotle's view with that of Kant, expressed in the following quotation:

\begin{quote}
\kant[2]
\end{quote}

\mynote{Should that be Aristotle, or would Plato be more demanding?}

\begin{answers}
\textbf{Answer Notes:}
bear this in mind: \kant[2]
\end{answers} 
\listoftodos
\end{document}
  • 1
    Thank you! This is helpful. Also thanks for not forgetting it :-). – JT_NL Oct 17 '12 at 16:09
  • 1
    @JonasTeuwen : Glad to be of help. I came home from my travels with much more work than I set out with, but I managed to find half-an-hour to knock that together. – Brent.Longborough Oct 17 '12 at 19:35