0

I have an edition of a document and I'd like to create a new edition with corrections on several places.

What's the best way to create a list of corrections?

I would imagine encapsulating the 'wrong' text with some command (e.g. \wrong{ }), and then encapsulating the corrected text by some other command (e.g. \fixed{ }). Then I could (a) get a list of corrections automatically by the page and section of each correction, and (b) toggle the display of the corrected version.

Is there anything like that I can use?

Thanks.

EDIT: I used the post proposed in the comments and modified to make this:

EDIT 2: Following the responses I made this correct as well, for future use. So this snippet now does what it should.

\documentclass{journal}

\long\def\addto#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}}
\def\correctionslist{}

\long\def\rightwrong#1#2{#1\edef\curpos{\arabic{section}.\arabic{subsection}}\expandafter\global\expandafter\addto\expandafter\correctionslist\expandafter{\curpos: RIGHT: #1\\ WRONG: #2  \par}}


\begin{document}
\newcommand{\curpos}{\arabic{section}.\arabic{subsection}}
\section{How to make cookies}
\subsection{Why do we want cookies?}
Cookies are tasty.

\rightwrong{
    We like any type.
}
{
    But only if they're Oreos.
}
\subsection{How do we make them?}
We need flour and sugar.
\rightwrong{
    Some sugar will suffice.
}
{
    Lots of sugar.
}

\section{List of corrections}
\correctionslist 

\end{document}

enter image description here

The problem is that \curpos is evaluated only when I call \correctionslist, so the section.subsection numbering is wrong. How can I solve this?

Thanks again.

5
  • 1
    You could look at the question tex.stackexchange.com/questions/276592/… and its answers. The commands there also collect their arguments, print part of it, and print the rest later.
    – jarauh
    Commented Nov 9, 2015 at 20:47
  • This doesn't exactly answer your question, but in case you aren't aware... the latexdiff perl utility will read both tex files, typeset the entire document, highlighting the differences. tug.ctan.org/tex-archive/help/Catalogue/entries/latexdiff.html
    – James
    Commented Nov 9, 2015 at 20:52
  • You can use the todonotes package to get colored margin notes, and also create a kind sort of list of corrections (list of todos) that you can create manually. In the section 1.8.13 Highligt text to fix, page 18 you can find an idea for your \wrong{}command. And for \fixed{} you can create your own easily.
    – Aradnix
    Commented Nov 9, 2015 at 21:22
  • Thanks. I edited the question - the solution is almost complete... I would appreciate any assistance in what's left to do.
    – yoki
    Commented Nov 10, 2015 at 12:53
  • 1
    Also related, my commenting package
    – Bordaigorl
    Commented Nov 10, 2015 at 13:02

1 Answer 1

1

One way to do it is to define \curpos inside \rightwrong by \edef. \edef makes sure that all macros are expanded immediately, so the current position is indeed saved. Also, one should add a few \expandafter to make sure that \curpos is expanded when \rightwrong is called.

\long\def\rightwrong#1#2{#1\edef\curpos{\arabic{section}.\arabic{subsection}}\expandafter\global\expandafter\addto\expandafter\correctionslist\expandafter{\curpos: RIGHT: #1\\ WRONG: #2  \par}}

There are some other things that should be done to make the output look nicer (e.g. separate different entries, add \noindent), but I guess the corresponding modifications should be "easy".

EDIT: added a few \expandafter to have \curpos directly evaluated when \rightwrong is called.

3
  • Thanks, but now it shows the section/subsection from the last call to rightwrong (in my example, both display "1.2").
    – yoki
    Commented Nov 10, 2015 at 18:17
  • Even if I add \edef\curpos{\arabic{section}.\arabic{subsection}} right before every call to rightwrong, I get the correct result on Section 1 but then on the correction list itself I get the 1.2 number in both.
    – yoki
    Commented Nov 10, 2015 at 18:25
  • 1
    You are right. I was enthusiastic when I saw the "1.2", so I didn't realize that one of them should have been a "1.1". I corrected my answer.
    – jarauh
    Commented Nov 11, 2015 at 13:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .