评论的运行数字

评论的运行数字

我希望将评论 1、评论 2 作为连续编号,并且对于每个审阅者,我想重新开始连续编号,有什么好方法可以实现吗?以下是 pdf 当前的样子,以及它的 latex(您可以看到我在 latex 中对数字进行了硬编码)。

在此处输入图片描述

 \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} 

答案1

有多个计数器的解决方案如下

\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}

在此处输入图片描述

答案2

我改进了解决方案,只用一个计数器

\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} 

快速而肮脏的解决方案:

\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} 

在此处输入图片描述

答案3

您在计数器“内”创建计数器。 chngectr这可能就是这里的窍门。值得一看。

\newcounter{reviewer} %创建新的反驳者

\counterwithin{comment}{reviewer} % 创建有评论者的评论

答案4

您还可以在此处添加标签\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}

在此处输入图片描述

你可能想说

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

而不是上面的代码;在这种情况下,最后的回复将被打印为

在此处输入图片描述

相关内容