# Problem compiling when I use symbols less than or greater than

I am writing a document with Texmaker and when I write some equation with the less than (<) or greater than (>) symbols, then it doesn't compile (it doesn't end compiling and I don't get error message).

If I write the equation without one of these symbols all is correct and the program compile. I have no idea why that happens.

The code is:

\documentclass[12pt,a4paper,oneside]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{listingsutf8}
\usepackage[spanish]{babel}
\usepackage{fancyhdr}
\usepackage[framed,numbered,autolinebreaks,useliterate]{mcode}
\lstset{breakatwhitespace=false}
\usepackage{lscape}
\usepackage{float}
\usepackage{breqn}
\bibliographystyle{plain}
\usepackage{array}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\usepackage{graphicx}
\usepackage{subfigure}
\graphicspath{{images/}}
\renewcommand{\baselinestretch}{1.5}
\lstset{
literate=%
{á}{{\'a}}1
{í}{{\'i}}1
{é}{{\'e}}1
{ó}{{\'o}}1
{ú}{{\'u}}1
{ñ}{{\~n}}1
{Á}{{\'A}}1
{Í}{{\'I}}1
{É}{{\'E}}1
{Ó}{{\'O}}1
{Ú}{{\'U}}1
{Ñ}{{\~N}}1
{¿}{{?}}1
{¡}{{!}}1
}
\begin{document}
$D_{P} < D < D_{o}$
\end{document}

Thanks

• Welcome to TeX.SX! Can you show us an example? Make a copy of your file, remove all the text except one such equation, and remove as much as code you can from the preamble without removing the problem. Can you also say which error you get? – Torbjørn T. May 4 '16 at 7:25
• Edited. The problem is in the math text at the end – beginner May 4 '16 at 7:46
• If you reduce the preamble, you end up with \documentclass{article} \usepackage[spanish]{babel} \usepackage{breqn} \begin{document} $<$ \end{document}. Remove either babel or breqn and it works. Do you use breqn elsewhere? – Torbjørn T. May 4 '16 at 7:55
• I have removed the '\usepackage{breqn}' and it worked. I thought I used it but finally not. Thank you!! – beginner May 4 '16 at 8:20

If you reduce your example further, you end up with the following:

\documentclass{article}
\usepackage[spanish]{babel}
\usepackage{breqn}
\begin{document}
$<$
\end{document}

So there is some interaction with breqn and babel which causes the problem. If no features of the breqn package are used, you can just remove \usepackage{breqn}.

However, it appears that this is a case where the loading order of packages matter; by swapping the order the example works.

\documentclass{article}
\usepackage{breqn}
\usepackage[spanish]{babel}
\begin{document}
$<$
\end{document}

The problem is in making babel-spanish and breqn into cooperating with each other.

With \usepackage[spanish]{babel}, the < character is made active, to mean

\es@use@shorthand <

This command transforms < into an other character via \string when LaTeX is in certain states or else executes the associated shorthand.

When in math, we of course want < to behave like the “less than” symbol, so \string< is applied which, in normal settings will do the right thing.

Not so when breqn is loaded, because it makes < into a math active character. This means that when < with category code 12 is found, TeX replaces it with its meaning as an active character. Well, the meaning as an active character is what has just been explained, so < is replaced by \string< which becomes a category code 12 <, so its meaning as an active character is used…

Oops! Infinite loop!

Loading breqn before babel is a solution, because in this case babel knows that there is already a meaning for < as an active character and uses it in math mode.

On the other hand, the features provided by < as a shorthand are very limited and the manual for babel-spanish says

Las incompatibilidades potenciales de estas abreviaciones son enormes.

(The potential incompatibilities of these shorthands are enormous.) So the best is to load

\usepackage[spanish,es-noquoting]{babel}

\documentclass[12pt,a4paper,oneside]{article}

% language and input
\usepackage[T1]{fontenc} % compulsory for Spanish
\usepackage[utf8]{inputenc}
\usepackage[spanish,es-noquoting]{babel}

% math facilities
\usepackage{amsmath}
\usepackage{breqn}

% other facilities
\usepackage{listingsutf8}
\usepackage{fancyhdr}
\usepackage{lscape}
\usepackage{float}
\usepackage{array}
\usepackage{graphicx}
\usepackage{subfig} % subfigure is obsolete

% non CTAN package
%\usepackage[framed,numbered,autolinebreaks,useliterate]{mcode}

%%% Settings

% pagination
\renewcommand{\baselinestretch}{1.5}

% generic
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
\graphicspath{{images/}}

% bibliography
\bibliographystyle{plain}

% listings
\lstset{breakatwhitespace=false}
\lstset{
literate=%
{á}{{\'a}}1
{í}{{\'i}}1
{é}{{\'e}}1
{ó}{{\'o}}1
{ú}{{\'u}}1
{ñ}{{\~n}}1
{Á}{{\'A}}1
{Í}{{\'I}}1
{É}{{\'E}}1
{Ó}{{\'O}}1
{Ú}{{\'U}}1
{Ñ}{{\~N}}1
{¿}{{?}}1
{¡}{{!}}1
}

Note that I changed subfigure into subfig, as the former is obsolete. Check the documentation of the latter package. You may want to use the more powerful subcaption package, though.

I commented out the call to mcode, because I don't have it.

Instead of setting \baselinestretch directly, you should consider using the setspace package (assuming you have to use large leading).

• same with babel-french + mathtools with centercolon which makes the colon math active. Loading mathastext solves the issue as it knows how to correctly handle Babel active characters. This general issue should be solved upstream at level of Babel package which should check in math mode for math activation and provide language authors an interface for what to do then. – user4686 May 4 '16 at 15:47