4

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

7
  • 1
    If the output is wrong, usually it means the input is wrong, so if you want help it is more useful to show your input than your output. Preferably a complete small document that reproduces the problem. Apr 12, 2015 at 9:10
  • 3
    LaTeX does split math mode expressions but only at certain points. By default there is no break at commas. Try adding an \allowbreak in the list expression, and/or have a look at tex.stackexchange.com/q/1959/15925 Apr 12, 2015 at 9:10
  • Please post the code that you used to generate this screenshot.
    – Mico
    Apr 12, 2015 at 9:11
  • I have updated the post with an MWE.
    – sherlock
    Apr 12, 2015 at 9:34
  • Out of curiosity: Why do you place [10pt] after {IEEEtran}?
    – Mico
    Apr 12, 2015 at 9:42

1 Answer 1

7

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}
2
  • 1
    +1 There's also: create a command that enables automatically breaking at commas like $G = (\breakatcommas{a,b,c,d,e,f,g,h,i})$.
    – Manuel
    Apr 12, 2015 at 10:16
  • @Manuel - I've provided an addendum to set up a LuaLaTeX-based solution to your "challenge". Feel free to post additional solutions. :-)
    – Mico
    Apr 12, 2015 at 12:06

Not the answer you're looking for? Browse other questions tagged .