Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm often writing scientific papers in collaboration with other authors, using a versioning system (mercurial) to manage the writing. When one of the authors wants to add a remark, we use a slightly enhanced version of marginpar. The problem is that in order to avoid to "pollute" the source code, the remark is removed once addressed, which sometimes makes it hard to keep track of the changes (even with mercurial, since revisions are not directly related with remarks).

Hence, I was wondering if there exists a way to have "external" notes to a Latex document, that are not in the source code, but can be included at compilation, by way of either absolute reference (e.g., line 140 of file.tex) or relative (e.g., at \label{lab}).

For instance, I could the following file, in the same directory than introduction.tex:

Note 1, line 237, introduction.tex: This definition does not work in this special case

SOLVED by commit 23

Note 2, \ref{def:test}: This definition still needs to work this special case

PENDING

When compiling the file introduction.tex, I could indicate to include the previous file, which would automatically add as a marginpar the Note 2, since it's PENDING.

share|improve this question
    
Even if there isn't any perfectly matching solution, I'd be interested in knowing any other solution with this principle of including extra content at compile time. –  Charles Morisset Dec 14 '12 at 13:57
    
Maybe a facility like the one provided by the todonotes package would help you : you can prefix the \todo command with \done once solved. –  T. Verron Dec 14 '12 at 13:59
    
@T.Verron: Thanks, I guess I could also comment the original \marginpar, but somehow, I'd like not to include the notes in the source code. –  Charles Morisset Dec 14 '12 at 14:04

1 Answer 1

up vote 9 down vote accepted

enter image description here

Main file

\documentclass{article}
\def\noteref#1#2{\csname noteref#2\endcsname{#1}}

\def\noterefSOLVED#1#2#3{}

\def\noterefPENDING#1#2#3{%
  \expandafter\def\csname noteref-#1\endcsname{\marginpar{#3}}}

\let\oldlabel\label
\def\label#1{%
\oldlabel{#1}%
\csname noteref-#1\endcsname}


\input{\jobname-notes}

\begin{document}

\section{intro\label{aa}}

stuff here stuff here stuff here stuff here stuff here stuff
stuff here stuff here stuff here stuff here stuff here stuff
stuff here stuff here stuff here stuff here stuff here stuff
stuff here stuff here stuff here stuff here stuff here stuff
\begin{enumerate}
\item thing one\label{bb}
\item thing two\label{cc}
\end{enumerate}
stuff here stuff here stuff here stuff here stuff here stuff
stuff here stuff here stuff here stuff here stuff here stuff
stuff here stuff here stuff here stuff here stuff here stuff
stuff here stuff here stuff here stuff here stuff here stuff
stuff here stuff here stuff here stuff here stuff here stuff

\end{document}

I used TeX markup in the comment file to make it easier, it would be possible to parse the plain text you suggested, but TeX is better at TeX markup:-)

\noteref{aa}{SOLVED}{by commit 23}
{This definition does not work in this special case}


\noteref{bb}{PENDING}{}
{This definition still needs to work this special case}
share|improve this answer
    
That looks quite nice, thanks! Just to be sure, the file containing "\noteref{aa}{SOLVED} ..." is in "jobname-notes", right? –  Charles Morisset Dec 14 '12 at 14:09
    
yes although it could be in anything as long as the \input matches. Also I just used a simple marginpar but you could spice it up a bit using todonotes or a similar package –  David Carlisle Dec 14 '12 at 14:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.