Consider the situation:
Two authors A,B (in fact, it will be four) inserting comments on a
texfile.Each author has his own command
\alertAand\alertBto insert comments.Each author should has his own counter
\ctrAand\ctrBwhich will be used during the comments.The command
\alert<?>{foo}should print the value of\ctr<?>at the position and insert at the margin again the value of the counter followed byfoo.Each author has his own colour
\clr<?>to be used for the output of his comments.
Partial code
I tried to define a global command \alert with 3 arguments: clr, ctr and text.
The clr should be optional, with default value black. If no colour is passed, the comments should be black.
\alert[red]{A}{foo} should make use of the counter \thectrA to insert foo and of course, step the counter.
Further, I simply have to define the commands \alert<?> with one argument (the comment) to be passed to \alert.
\newcommand{\alertA}[1]{\alert[blue]{\thectrA}{#1}}
\newcommand{\alertB}[1]{\alert[red]{\thectrB}{#1}}
The use in the text should be simply
... as we have\alertA{comments here} and so on...
... after a lot of text\alertB{more comments here} and so on...
At the end I'd like to have two independent sets of comments with two enumerations and two colours.
M(non working)WE
As you can see there is a problem with the counters. They are constant equal to 1.
\documentclass{report}
\usepackage{xcolor}
\newcounter{alert}
\newcounter{ctrA}
\newcounter{ctrD}
\newcounter{ctrM}
\newcounter{ctrT}
\setcounter{alert}{1}
\setcounter{ctrA}{1}
\setcounter{ctrD}{1}
\setcounter{ctrM}{1}
\setcounter{ctrT}{1}
\newcommand{\alert}[3][black]{% #3=texto, #2=ctr #1=color
\renewcommand{\thealert}{#2}
\rlap{\textsuperscript{\textsuperscript{\textcolor{#1}{\textbf{\thealert}}}}}%
\marginpar{\raggedright\footnotesize\textcolor{#1}{\llap{\textsuperscript{\textit{\thealert}}}#3}}%
\stepcounter{alert}%
}
\newcommand{\alertA}[1]{\alert[red]{\thectrA}{#1}}
\newcommand{\alertD}[1]{\alert[blue]{\thectrD}{#1}}
\begin{document}
... as we have\alertA{comments here} and so on...
... after a lot of text\alertD{more comments here} and so on...
... as we have\alertA{comments here} and so on...
... after a lot of text\alertD{more comments here} and so on...
... as we have\alertA{comments here} and so on...
... after a lot of text\alertD{more comments here} and so on...
... as we have\alertA{comments here} and so on...
... after a lot of text\alertD{more comments here} and so on...
\end{document}




ctrA. – egreg Jun 02 '15 at 19:21