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?