[Tex/LaTex] Improper formatting in Math mode in IEEEtran double column format

math-mode

I am authoring a document in IEEE transaction double column format. Inline Math equations are being rendered improperly, mostly there are unwanted spaces between symbols (as I have highlighted below). I understand that Latex has to adjust text spacing to justify the columns. Can there be any means to instruct Latex to split Math mode expressions as well to reduce redundant space insertion?

\documentclass{IEEEtran}[10pt]
\usepackage{amsfonts}

\begin{document}
A bilinear pairing defined to be $ \mathcal{G} = (p,\mathbb{G}_a,\mathbb{G}_b,\mathbb{G}_T,e,P_a,P_b)$ where we choose $\mathbb{G}_a=\langle P_a \rangle$
\end{document}

enter image description here

Best Answer

I think you have two options:

  • Insert one or more judiciously chosen \allowbreak directives inside the inline math equation to allow line breaks after one of the commas, or

  • Convert the inline equation to a displayed equation, as (i) the equation may be sufficiently important to merit this treatment and (ii) you're dealing with fairly narrow columns.

enter image description here

\documentclass{IEEEtran}
\usepackage{amsfonts} % for "\mathbb" macro
\begin{document}

A bilinear pairing defined to be
$\mathcal{G}=(p, \mathbb{G}_a, \mathbb{G}_b, \mathbb{G}_T, e, \allowbreak P_a, \allowbreak P_b)$, 
where we choose $\mathbb{G}_a=\langle P_a\rangle$, \dots

\begin{center} --------- or --------- \end{center}  % just for visual interest

A bilinear pairing defined to be
\[
\mathcal{G}=(p, \mathbb{G}_a, \mathbb{G}_b, \mathbb{G}_T, e, P_a, P_b)\,,
\] 
where we choose $\mathbb{G}_a=\langle P_a\rangle$, \dots
\end{document}

Addendum, inspired by a comment by Manuel. While it may be a bit overkill for the immediate example at hand, it may be useful to have a function or macro which enables line breaks after commas when in math mode. If switching to LuaLaTeX is an option for you, the following code should be of interest to you. It sets up two TeX macros named \breakatcommas and \nobreakatcommas which enable and suppress, respectively, line breaking at commas. Issue \breakatcommas before the line(s) that should permit this kind of line breaking, and issue \nobreakcommas after the line(s) in question.

enter image description here

% !TEX TS-program = lualatex
\documentclass{IEEEtran}
\usepackage{amsfonts} % for '\mathbb' macro

\usepackage{luacode,luatexbase} 
\begin{luacode}
function breakatcommas ( line )
    line = string.gsub ( line, ",", ",\\allowbreak" )
    return line
end
\end{luacode}
\newcommand\breakatcommas{\directlua{luatexbase.add_to_callback 
    ( "process_input_buffer", breakatcommas, "breakatcommas") }}
\newcommand\nobreakatcommas{\directlua{luatexbase.remove_from_callback 
    ( "process_input_buffer", "breakatcommas") }}

\begin{document}
A bilinear pairing defined to be
\breakatcommas
$\mathcal{G}=(p, \mathbb{G}_a, \mathbb{G}_b, \mathbb{G}_T, e, P_a, P_b)$ 
\nobreakatcommas 
where we choose $\mathbb{G}_a=\langle P_a \rangle$, \dots
\end{document}