在 \title 中插入查询的问题

在 \title 中插入查询的问题

我正在使用marginnote包来插入查询。但\title我无法打印查询。

有人能告诉我问题出在哪里吗?

请检查我是否已经更改了代码:

\documentclass{article}

\usepackage{xifthen,array}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Queries %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\newwrite\@qrynotes
\newif\if@qrynotesopen \global\@qrynotesopenfalse

\def\@openqrynotes{\immediate\openout\@qrynotes=\jobname\thechapqry.qry\relax
%\immediate\write\@auxout{\string\newif\csname if\jobname\roman{chapqry}\endcsname}
%\expandafter\csname if\jobname\roman{chapqry}\endcsname%
%\expandafter\global\csname jobname\roman{chapqry}false\endcsname
      \global\@qrynotesopentrue}

\long\def\Protected@immwrite#1#2{%
      \begingroup%
       \let\protect\@unexpandable@protect%
       \edef\reserved@a{\immediate\write#1{\fontsize{12bp}{14bp}\selectfont #2}}%
       \reserved@a%
      \endgroup}%

\newif\ifbwf@querymark\bwf@querymarktrue
\newif\ifprintquery\global\printqueryfalse

\newcounter{chapqry}
\setcounter{chapqry}{0}

\newcounter{qrycount}[chapqry]

\newdimen\querywidth

\querywidth=3pc

\def\defaultcondition{TRUE}

\DeclareRobustCommand\AQ{\unskip\@ifnextchar[{\@AQtbmove}{\@AQprint}}%

\def\@AQtbmove[#1]#2{\@ifnextchar[{\@AQtbmoveprint[#1]{#2}}{\@AQtbmoveprint[#1]{#2}[0pt]}}%

\def\@AQtbmoveprint[#1]#2[#3]{\ifbwf@querymark\stepcounter{qrycount}%
\if@qrynotesopen \else  \@openqrynotes \fi%
 \Protected@immwrite\@qrynotes{\string AQ\the\c@qrycount & #2 &\protect\\ }%
% \ifnum\thechapqry=\thechapqry
%\expandafter\if\csname jobname\roman{chapqry}\endcsname
\expandafter\ifx\csname processcount\roman{chapqry}\endcsname\defaultcondition%
 \AQ@margtext[#1]{AQ\the\c@qrycount}[#3]%
\fi\fi}%

\def\@AQprint#1{\@ifnextchar[{\@AQprintquery{#1}}{\@AQprintquery{#1}[0pt]}}%

\def\@AQprintquery#1[#2]{\ifbwf@querymark\stepcounter{qrycount}%
\if@qrynotesopen \else  \@openqrynotes \fi%
 \Protected@immwrite\@qrynotes{\string AQ\the\c@qrycount & #1 & \\ }%
% \expandafter\if\csname jobname\roman{chapqry}\endcsname
\expandafter\ifx\csname processcount\roman{chapqry}\endcsname\defaultcondition%
 {\AQ@margtext[0pt]{AQ\the\c@qrycount}[#2]}%
\fi\fi}%

\newif\if@rightcolumnquery\global\@rightcolumnqueryfalse%

\def\RAQ#1{\global\@rightcolumnquerytrue\AQ{#1}}

\newdimen\lastpagetotaldim
\def\AQ@margtext[#1]#2[#3]{%
  \ifmmode%
  \else%
    \setbox\@tempboxa=\vbox to 0pt{\vskip-9pt\vskip#1%
    \if@rightcolumnquery%
    \global\@rightcolumnqueryfalse%
      \hbox to \hsize{\hfill\hskip#3\rlap{\hbox to \querywidth{\hskip12pt\reset@font\normalcolor\normalsize #2\hfill}}}%
    \else%
      \ifdim\pagetotal=\lastpagetotaldim{\protect\par\vskip12pt}\else\fi%
      \global\lastpagetotaldim=\pagetotal%
      \hbox to \hsize{\hskip#3\llap{\hbox to \querywidth{\reset@font\normalcolor\normalsize #2\hfill}}\hfill}%
    \fi}%
    \dp\@tempboxa\z@%
    \ifvmode%
      \@tempdima=\prevdepth%
      \nointerlineskip\box\@tempboxa\nobreak%
      \prevdepth=\@tempdima%
    \else%
      \vadjust{\box\@tempboxa\nobreak}\space%
    \fi%
  \fi\penalty10000%
}
\newbox\qrylabelbox

\newenvironment{qrylist}[1][\relax]{%
\list{}%
{\setbox\qrylabelbox\hbox{\normalsize#1.}
\labelsep8pt
\labelwidth\wd\qrylabelbox%
\leftmargin\labelwidth%
\advance\leftmargin\labelsep%
\rightmargin\z@%
\def\makelabel##1{\hbox to \labelwidth{\hfill##1.}}}%
}%
{\endlist}

\def\notesname{\fontfamily{ptm}\fontsize{17bp}{17bp}\selectfont\bfseries Author Query Form}%
\def\qnoteheading{%
\clearpage%
\gdef\watermarktext{}
\addtocounter{page}{-1}%
\pagestyle{empty}
\ifthenelse{\isodd{\thepage}}{\addtocounter{page}{-1}}{\addtocounter{page}{-1}}
\vspace*{-7pc}
%\lineno@off%
%\ifbwf@rmblankpage
%\addtocounter{page}{-1}%
%\setcounter{curpage}{\arabic{page}}
%\else
%\setcounter{curpage}{\arabic{page}}
%\ifodd\thecurpage
%\addtocounter{curpage}{-1}%
%\fi%
\fi%
\centerline{\notesname}%
\rule{\textwidth}{1pt}\vskip2\baselineskip\noindent{\fontfamily{ptm}\fontsize{12bp}{12bp}\selectfont\bfseries Journal: Statistics in Medicine\par\addvspace{10.5\p@}Article: STA\par\addvspace{20pt}}\fontfamily{ptm}\fontsize{12bp}{14bp}\selectfont Dear Author,\par\addvspace{2pc} During the copyediting of your paper,the following queries arose. Please respond to these by annotating your proofs with the necessary changes/additions.\begin{itemize}
\item If you intend to annotate your proof electronically, please refer to the E-annotation guidelines.
\item If you intend to annotate your proof by means of hard-copy mark-up, please refer to the proofmark-upsymbols guidelines.
If manually writing corrections on your proof and returning it by fax, do not write
too close to the edge of the paper. Please remember that illegible mark-ups may delay publication
\end{itemize}
Whether you opt for hard-copy or electronic annotation of your proofs,
were commend that you provide additional clarification of answers to queries
by entering your answers on the query sheet, in addition to the textmark-up.
}

\RequirePackage{longtable}
\def\printquery{
\immediate\write\@auxout{\string\gdef\expandafter\string\csname processcount\roman{chapqry}\endcsname{TRUE}}\printquerytrue\ifprintquery%\immediate\write\@auxout{\expandafter\string\expandafter\global\csname\jobname\roman{chapqry}true\endcsname}%
\immediate\closeout\@qrynotes \global\@qrynotesopenfalse%
%%
\ifnum\c@qrycount>0
\qnoteheading
\vspace*{2pc}

\begin{longtable}{@{}|l|>{\raggedright\parindent0pt}p{.6\textwidth}|p{.175\textwidth}|@{}}\hline%
\textbf{Query No.} & \textbf{Query} & \textbf{Remark}\\
\endfirsthead
\hline
\textbf{Query No.} & \textbf{Query} & \textbf{Remark}\\
\hline
\endhead
\hline
\multicolumn{1}{c}{}& \multicolumn{1}{c}{}& \multicolumn{1}{r}{\hfill (Continued..)}\\
\endfoot
\hline
\endlastfoot
\hline
\input{\jobname\thechapqry.qry}
\hline
\end{longtable}
\fi\par\addvspace{24\p@}
%\fi%\lineno@on\setcounter{lastpage}{\arabic{page}}\addtocounter{lastpage}{-\c@curpage}
}%

%
%%%%%%%%%% Author query part end %%%%%%%%%%%%
\makeatother

\begin{document}

\title{title}
\author{author}
\maketitle

this is a sample\AQ{first query} document


\printquery
\end{document} 

答案1

问题源于 的书写& & \\。当\\展开时,它似乎会弄乱\AQ。我必须承认,我不完全明白那里发生了什么。但以下内容将解决您的问题:

\Protected@immwrite\@qrynotes{\string AQ\the\c@qrycount & #1 & \protect\\ }%

\def\@AQprintquery#1[#2]\def\@AQtbmoveprint[#1]#2[#3]这已经完成了,因此前者不保护 ,这很奇怪\\

我认为这已经足够清楚了,我不必重复整个代码。但为了消除任何误解,这里是:

\documentclass{article}

\usepackage{xifthen,array}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Queries %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\newwrite\@qrynotes
\newif\if@qrynotesopen \global\@qrynotesopenfalse

\def\@openqrynotes{\immediate\openout\@qrynotes=\jobname\thechapqry.qry\relax
%\immediate\write\@auxout{\string\newif\csname if\jobname\roman{chapqry}\endcsname}
%\expandafter\csname if\jobname\roman{chapqry}\endcsname%
%\expandafter\global\csname jobname\roman{chapqry}false\endcsname
      \global\@qrynotesopentrue}

\long\def\Protected@immwrite#1#2{%
      \begingroup%
       \let\protect\@unexpandable@protect%
       \edef\reserved@a{\immediate\write#1{\fontsize{12bp}{14bp}\selectfont #2}}%
       \reserved@a%
      \endgroup}%

\newif\ifbwf@querymark\bwf@querymarktrue
\newif\ifprintquery\global\printqueryfalse

\newcounter{chapqry}
\setcounter{chapqry}{0}

\newcounter{qrycount}[chapqry]

\newdimen\querywidth

\querywidth=3pc

\def\defaultcondition{TRUE}

\DeclareRobustCommand\AQ{\unskip\@ifnextchar[{\@AQtbmove}{\@AQprint}}%

\def\@AQtbmove[#1]#2{\@ifnextchar[{\@AQtbmoveprint[#1]{#2}}{\@AQtbmoveprint[#1]{#2}[0pt]}}%

\def\@AQtbmoveprint[#1]#2[#3]{\ifbwf@querymark\stepcounter{qrycount}%
\if@qrynotesopen \else  \@openqrynotes \fi%
 \Protected@immwrite\@qrynotes{\string AQ\the\c@qrycount & #2 &\protect\\ }%
% \ifnum\thechapqry=\thechapqry
%\expandafter\if\csname jobname\roman{chapqry}\endcsname
\expandafter\ifx\csname processcount\roman{chapqry}\endcsname\defaultcondition%
 \AQ@margtext[#1]{AQ\the\c@qrycount}[#3]%
\fi\fi}%

\def\@AQprint#1{\@ifnextchar[{\@AQprintquery{#1}}{\@AQprintquery{#1}[0pt]}}%

\def\@AQprintquery#1[#2]{\ifbwf@querymark\stepcounter{qrycount}%
\if@qrynotesopen \else  \@openqrynotes \fi%
 \Protected@immwrite\@qrynotes{\string AQ\the\c@qrycount & #1 &\protect\\ }%
% \expandafter\if\csname jobname\roman{chapqry}\endcsname
\expandafter\ifx\csname processcount\roman{chapqry}\endcsname\defaultcondition%
 {\AQ@margtext[0pt]{AQ\the\c@qrycount}[#2]}%
\fi\fi}%

\newif\if@rightcolumnquery\global\@rightcolumnqueryfalse%

\def\RAQ#1{\global\@rightcolumnquerytrue\AQ{#1}}

\newdimen\lastpagetotaldim
\def\AQ@margtext[#1]#2[#3]{%
  \ifmmode%
  \else%
    \setbox\@tempboxa=\vbox to 0pt{\vskip-9pt\vskip#1%
    \if@rightcolumnquery%
    \global\@rightcolumnqueryfalse%
      \hbox to \hsize{\hfill\hskip#3\rlap{\hbox to \querywidth{\hskip12pt\reset@font\normalcolor\normalsize #2\hfill}}}%
    \else%
      \ifdim\pagetotal=\lastpagetotaldim{\protect\par\vskip12pt}\else\fi%
      \global\lastpagetotaldim=\pagetotal%
      \hbox to \hsize{\hskip#3\llap{\hbox to \querywidth{\reset@font\normalcolor\normalsize #2\hfill}}\hfill}%
    \fi}%
    \dp\@tempboxa\z@%
    \ifvmode%
      \@tempdima=\prevdepth%
      \nointerlineskip\box\@tempboxa\nobreak%
      \prevdepth=\@tempdima%
    \else%
      \vadjust{\box\@tempboxa\nobreak}\space%
    \fi%
  \fi\penalty10000%
}
\newbox\qrylabelbox

\newenvironment{qrylist}[1][\relax]{%
\list{}%
{\setbox\qrylabelbox\hbox{\normalsize#1.}
\labelsep8pt
\labelwidth\wd\qrylabelbox%
\leftmargin\labelwidth%
\advance\leftmargin\labelsep%
\rightmargin\z@%
\def\makelabel##1{\hbox to \labelwidth{\hfill##1.}}}%
}%
{\endlist}

\def\notesname{\fontfamily{ptm}\fontsize{17bp}{17bp}\selectfont\bfseries Author Query Form}%
\def\qnoteheading{%
\clearpage%
\gdef\watermarktext{}
\addtocounter{page}{-1}%
\pagestyle{empty}
\ifthenelse{\isodd{\thepage}}{\addtocounter{page}{-1}}{\addtocounter{page}{-1}}
\vspace*{-7pc}
%\lineno@off%
%\ifbwf@rmblankpage
%\addtocounter{page}{-1}%
%\setcounter{curpage}{\arabic{page}}
%\else
%\setcounter{curpage}{\arabic{page}}
%\ifodd\thecurpage
%\addtocounter{curpage}{-1}%
%\fi%
\fi%
\centerline{\notesname}%
\rule{\textwidth}{1pt}\vskip2\baselineskip\noindent{\fontfamily{ptm}\fontsize{12bp}{12bp}\selectfont\bfseries Journal: Statistics in Medicine\par\addvspace{10.5\p@}Article: STA\par\addvspace{20pt}}\fontfamily{ptm}\fontsize{12bp}{14bp}\selectfont Dear Author,\par\addvspace{2pc} During the copyediting of your paper,the following queries arose. Please respond to these by annotating your proofs with the necessary changes/additions.\begin{itemize}
\item If you intend to annotate your proof electronically, please refer to the E-annotation guidelines.
\item If you intend to annotate your proof by means of hard-copy mark-up, please refer to the proofmark-upsymbols guidelines.
If manually writing corrections on your proof and returning it by fax, do not write
too close to the edge of the paper. Please remember that illegible mark-ups may delay publication
\end{itemize}
Whether you opt for hard-copy or electronic annotation of your proofs,
were commend that you provide additional clarification of answers to queries
by entering your answers on the query sheet, in addition to the textmark-up.
}

\RequirePackage{longtable}
\def\printquery{
\immediate\write\@auxout{\string\gdef\expandafter\string\csname processcount\roman{chapqry}\endcsname{TRUE}}\printquerytrue\ifprintquery%\immediate\write\@auxout{\expandafter\string\expandafter\global\csname\jobname\roman{chapqry}true\endcsname}%
\immediate\closeout\@qrynotes \global\@qrynotesopenfalse%
%%
\ifnum\c@qrycount>0
\qnoteheading
\vspace*{2pc}

\begin{longtable}{@{}|l|>{\raggedright\parindent0pt}p{.6\textwidth}|p{.175\textwidth}|@{}}\hline%
\textbf{Query No.} & \textbf{Query} & \textbf{Remark}\\
\endfirsthead
\hline
\textbf{Query No.} & \textbf{Query} & \textbf{Remark}\\
\hline
\endhead
\hline
\multicolumn{1}{c}{}& \multicolumn{1}{c}{}& \multicolumn{1}{r}{\hfill (Continued..)}\\
\endfoot
\hline
\endlastfoot
\hline
\input{\jobname\thechapqry.qry}
\hline
\end{longtable}
\fi\par\addvspace{24\p@}
%\fi%\lineno@on\setcounter{lastpage}{\arabic{page}}\addtocounter{lastpage}{-\c@curpage}
}%

%
%%%%%%%%%% Author query part end %%%%%%%%%%%%
\makeatother

\begin{document}

\title{title \AQ{test}}
\author{author}
\maketitle

this is a sample\AQ{first query} document


\printquery
\end{document}

只是为了向你展示一下 MWE 应该是什么样的:

\documentclass{article}

\makeatletter
\newwrite\@qrynotes
\immediate\openout\@qrynotes=\jobname.qry\relax

 \DeclareRobustCommand\AQ[1]{%
    \begingroup%
     \let\protect\@unexpandable@protect%
     \edef\tmp@a{\immediate\write\@qrynotes{AQ55 & #1 & \protect\\}}%
     \tmp@a%
    \endgroup
}
\makeatother

\begin{document}

\title{title \AQ{title}}
\author{author}
\maketitle

this is a sample\AQ{first query} document
\end{document}

当然,这不再包含完整的功能。但它会引发错误,从而允许修复它。

相关内容