In answering another question allowing line break at ',' in inline math mode, Stefan Kottwitz suggested two excellent ways to allow line breaks in inline math mode after ,. One way was to use the \allowbreak command after the comma, and the other way was to globally redefine , so that line breaks are allowed.
I used the second approach, and was really fond of it, until I noted that the command \cite{} no longer works as expected: If I cited more than one reference, it showed [?] instead of the correct citation. Here's an example:
\documentclass{article}
%----------Redefining `,` ------------------%
\makeatletter
\def\old@comma{,}
\catcode`\,=13
\def,{%
\ifmmode%
\old@comma\discretionary{}{}{}%
\else%
\old@comma%
\fi%
}
\makeatother
%-------------------------------------------%
\begin{document}
\cite{A,B}
\begin{thebibliography}{A}
\bibitem{A} ABC
\bibitem{B} DEF
\end{thebibliography}
\end{document}
What is wrong with redefining ,? How to correct it?
,only in the mathmode, so that\citedoes not encounter such problem? – Sadeq Dousti May 26 '11 at 10:19\mathlist! – Riccardo T. Jun 11 '12 at 13:38\AtBeginDocument-block and the\catcode-group thereafter?) – Lover of Structure Feb 03 '13 at 07:41\disallowlinebreak). (2) Similarly, if I include\allowbreakin a macro, I'd like a manual way of disabling this (for both the case where\allowbreakoccurs at the beginning and where it occurs at the end of a macro definition). — Let me know if you think it'd be useful for me to ask about these two things in one or two separate questions. – Lover of Structure Feb 03 '13 at 12:18