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 am using marginnote package for inserting queries. But in \title I am unable to print query.

Can anybody suggest me what is the problem?

please check now I have changed the code:

\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} 
share|improve this question
1  
Welcome to TeX.SX. Please add a fully compilable minimal working example (MWE) that illustrates your problem. –  canaaerus Jul 26 '12 at 5:48
    
Actually I am creating queries list from tex file by using \AQ command. it is generating the file. but it is showing some error like ! Argument of \@AQprintquery has an extra }. can somebody help me what is this error? –  Varaprasad Jul 27 '12 at 5:41
    
You should always create a minimal example. It helps others reproduce your problem. Also, as in the creation process you strip away everything that has nothing to do with the actual problem, you may even find a solution yourself. In this case I don't even know what \AQ is. So please be a little more explicit. –  canaaerus Jul 27 '12 at 6:13
    
Wow, that certainly does not look minimal. And still — if I remove the \AQ from \title and \author there are a ton of errors. Please give something that works except for the issue you try to solve here. –  canaaerus Jul 27 '12 at 6:28
    
can you try now? thanks –  Varaprasad Jul 27 '12 at 6:32

1 Answer 1

The problem stems from the writing of & & \\. When \\ gets expanded, it seems to mess up \AQ. I must admit, that I don't fully understand what's going on there. But the following will fix your problem:

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

in \def\@AQprintquery#1[#2]. In \def\@AQtbmoveprint[#1]#2[#3] this is already done, so its peculiar that the former does not protect \\.

I thought this was clear enough and I didn't have to repeat the whole code. But to get any misunderstanding out of the way, here it is:

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

And just to show you, what a MWE would have to look like:

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

Of course this does not contain the complete functionality any more. But it invokes the error and thus allows to fix it.

share|improve this answer
    
But, the output is not printing. –  Varaprasad Jul 27 '12 at 10:15
    
@Varaprasad: Does it work for you now? –  canaaerus Jul 28 '12 at 5:39
    
No, i think there is some problem –  Varaprasad Jul 28 '12 at 9:35
    
@Varaprasad: Ok I didn't have the \AQ in \title, but that's all. I added it. The code compiles fine. Now the document contains a AQ1 note left to the title and the query list contains the entry too. –  canaaerus Jul 28 '12 at 9:51
    
@Varaprasad: Please accept the answer if it works, or say so if you still have problems! –  canaaerus Jul 31 '12 at 9:20

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.