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 wish to have comment 1, comment 2 as running numbers, and for each reviewer I want to restart the running number, is there a good way to achieve this? Following is how the pdf currently looks, and its latex (you can see that I hard code the number in the latex).

enter image description here

 \documentclass{article}
    \usepackage[usenames]{color}

    \begin{document}
    \setlength{\parindent}{0pt}
    \setlength{\parskip}{2ex}


    \title{Change Summary}

    \author{This is author}

    \maketitle


    We are thankful for the valuable and insightful comments from referees.
    These comments have helped us to improve our work.
    We have fixed the typos and language problems based on the reviews.
    The rest of the comments are addressed in the following.

    \section*{Reviewer 1}
    \textbf{Comment 1}:
    This is comment 1

    \textbf{Reply}: This is reply 1
    .

    \textbf{Comment 2}: This is comment 2

    \textbf{Reply}:
    This is reply 2

    \section*{Reviewer 2}
    \textbf{Comment 1}: This is comment 1

    \textbf{Reply}: This is Reply 1

    \end{document} 
share|improve this question
add comment

4 Answers 4

With several counters a solution reads

\documentclass{article}
\makeatletter
\newcounter{reviewer}\setcounter{reviewer}{0}
\newcounter{comment}\setcounter{comment}{0}
\newcounter{reply}\setcounter{reply}{0}
\@addtoreset{comment}{reviewer}
\@addtoreset{reply}{reviewer}
\def\reviewer{\stepcounter{reviewer}\section*{Reviewer \arabic{reviewer}}}
\def\comment{\stepcounter{comment}\textbf{Comment \arabic{comment}:}}
\def\reply{\stepcounter{reply}\textbf{Reply \arabic{reply}:}}
\begin{document}
\setlength{\parindent}{0pt}
%\setlength{\parskip}{2ex} please do not set \parskip, use package setspace instead
\title{Change Summary}
\author{This is author}
\maketitle
We are thankful for the valuable and insightful comments from referees.
These comments have helped us to improve our work.
We have fixed the typos and language problems based on the reviews.
The rest of the comments are addressed in the following.
\reviewer
\comment\ This is comment 1

\reply\ This is reply 1.

\comment\ This is comment 2

\reply\ This is reply 2

\reviewer
\comment\ This is comment 1

\reply\ This is Reply 1
\end{document}

enter image description here

share|improve this answer
add comment

I improved the solution, with just one counter

\documentclass{article}
\usepackage{tocloft}
\usepackage[usenames]{color}

\newcounter{CommentReply}[section]


\newcommand{\CommentReply}[2]{%
  \addtocounter{CommentReply}{1}%
  \textbf{Comment \theCommentReply:} #1 

  \textbf{Reply \theCommentReply:} #2

}

\begin{document}

\pretocmd{\section}{\setcounter{CommentReply}{0}}{}{}


\setlength{\parindent}{0pt}
\setlength{\parskip}{2ex}




    \title{Change Summary}

    \author{This is author}

    \maketitle


    We are thankful for the valuable and insightful comments from referees.
    These comments have helped us to improve our work.
    We have fixed the typos and language problems based on the reviews.
    The rest of the comments are addressed in the following.

    \section*{Reviewer 1}

    \CommentReply{This is comment 1}{This is reply 1}


    \CommentReply{This is comment 2}{This is reply 2}

    \section*{Reviewer 2}

    \CommentReply{This is comment 1}{This is reply 1}


    \CommentReply{This is comment 2}{This is reply 2}



    \end{document} 

Quick and dirty solution:

\documentclass{article}

    \usepackage[usenames]{color}

    \newcounter{CommentReply}[section]
    \newcommand{\CommentReply}[2]{%
      \refstepcounter{CommentReply}%

      \textbf{Comment \theCommentReply:}  #1%

      \textbf{Reply \theCommentReply:}   #2%

      }

    \begin{document}
    \setlength{\parindent}{0pt}
    \setlength{\parskip}{2ex}




    \title{Change Summary}

    \author{This is author}

    \maketitle


    We are thankful for the valuable and insightful comments from referees.
    These comments have helped us to improve our work.
    We have fixed the typos and language problems based on the reviews.
    The rest of the comments are addressed in the following.

    \section*{Reviewer 1}

    \CommentReply{This is comment 1}{This is reply 1}


    \CommentReply{This is comment 2}{This is reply 2}

    \setcounter{CommentReply}{0}% 
    \section*{Reviewer 2}

    \CommentReply{This is comment 1}{This is reply 1}


    \CommentReply{This is comment 2}{This is reply 2}



    \end{document} 

enter image description here

share|improve this answer
add comment

You create a counter "within" a counter. chngectr might be just the trick here. It is worth looking at.

\newcounter{reviewer} %create new counter reviewer

\counterwithin{comment}{reviewer} % create comment witnin reviewer

share|improve this answer
add comment

Here you can also add labels for \ref:

\documentclass{article}

\newcounter{reviewer}
\newcounter{comment}[reviewer] % comment is reset when reviewer is stepped
\makeatletter
\renewcommand\p@comment{\thereviewer.}
\makeatother

\newcommand{\reviewer}{%
  \refstepcounter{reviewer}%
  \section*{Reviewer \thereviewer}
}
\newcommand{\comment}{%
  \par\addvspace{2ex}\noindent
  \refstepcounter{comment}%
  \textbf{Comment \thecomment:}\enspace\ignorespaces
}
\newcommand{\reply}{%
  \par\addvspace{1ex}
  \noindent\textbf{Reply:}\enspace\ignorespaces
}

\begin{document}


\title{Change Summary}

\author{This is author}

\maketitle


We are thankful for the valuable and insightful comments from referees.
These comments have helped us to improve our work.
We have fixed the typos and language problems based on the reviews.
The rest of the comments are addressed in the following.

\reviewer
\comment
This is comment 1

\reply
This is reply 1


\comment\label{rev1-comm2}
This is comment 2

\reply
This is reply 2


\reviewer
\comment
This is comment 1

\reply
This is Reply 1 (see \ref{rev1-comm2})

\end{document}

enter image description here

You may want to say

\renewcommand\p@comment{Reviewer~\thereviewer, Comment~}

instead of the code above; in this case the last reply would be printed as

enter image description here

share|improve this answer
add comment

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.