# Overflow out of margin at inline reference citation

In my writing, I see that sometimes the text doesn't follow the margin imposed when a reference is added a the end of the word.

Here is an example:

The associated code is (I broke the line to make is more readable):

\documentclass[12pt, english, onehalfspacing, headsepline]{MastersDoctoralThesis}
\begin{document}
Region-growing methods are particularly appropriate to segment large homogeneous connected regions
and have been employed for numerous segmentation tasks in medical imaging using MRI such as ventricular
blood pool segmentation\Cup{muhlenbruch2006global} or LA segmentation\Cup{zhu2013automatic}.
However, region growing approaches are sensitive to noise which can impair correct pixel annotation
and lead to holes in the region of interest.
Moreover, region growing methods still require manual tuning such as selecting
an appropriate seeding location and defining efficient similarity criterion
to prevent the algorithm to "leak" outside of the region of interest.
\end{document}


With:

\newcommand\Cup[1]{\textsuperscript{\cite{#1}}}


Is there a way to improve the situation ?

EDIT: I am using a template from Overleaf:

% Masters/Doctoral Thesis
% LaTeX Template
% Version 2.5 (27/8/17)
%
% http://www.LaTeXTemplates.com
%
% Version 2.x major modifications by:
% Vel (vel@latextemplates.com)
%
% This template is based on a template by:
% Steve Gunn (http://users.ecs.soton.ac.uk/srg/softwaretools/document/templates/)
% Sunil Patel (http://www.sunilpatel.co.uk/thesis-template/)
%


The other issues seem similar:

I imagine that the second example is due to the use of $\pm$. However, I am not too sure. Moreover, I don't know why the third one appears.

Here is the related code:

Misalignment 2:

(Dice score 93.67$\pm$0.2\% vs 92.91$\pm$0.38\%, MSD 0.689$\pm$0.107mm vs
0.791$\pm$0.047mm, \textit{p}-value < 0.01). On the other hand, the application
of solely histogram augmentations (gamma, CLAHE and add) (purple bars in Figure
\ref{data_aug_final} A and B) significantly decrease the accuracy scores (Dice
score 92.23$\pm$0.6\% vs 92.91$\pm$0.38\%, MSD 0.917$\pm$0.129mm vs
0.791$\pm$0.047mm,\textit{p}-value < 0.01). Even if removing the add data
augmentation improves the results, this


Misalignment 3:

    Using \textit{histogram augmentations} only the modification of the contrast
using gamma showed improvements on the Dice score (93.06$\pm$0.51\% vs
92.93$\pm$0.38\% using no data augmentation). No Dice score modification was
yielded by using CLAHE (92.96\% vs 92.93\%) and "add" worsened the results lower
the Dice score (92.66\% vs 92.93\%). For the MSD metrics, only the CLAHE improved
the final score (0.758$\pm$0.06 vs 0.767$\pm$0.08mm) while "add"


Is there a package that I am not using correctly ?

I used these packages:

\usepackage[utf8]{inputenc} % Required for inputting international characters
\usepackage[T1]{fontenc} % Output font encoding for international characters
\usepackage{tocbibind}
\usepackage{mathpazo} % Use the Palatino font by default
\usepackage[backend=biber,style=ieee]{biblatex}
\usepackage[font=singlespacing, font=small]{caption}
\usepackage[autostyle=true]{csquotes}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{textcomp}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{siunitx}
\usepackage{amsfonts, amsmath, amsthm, amssymb}
\usepackage{color,soul}
\usepackage{float}
\usepackage{array}


EDIT 2: These later issues were fixed using the microtype package as \usepackage{microtype} in the "package definition section". However, some references are still not quite tidy.

Example:

Is there another/special package for it ?

Kind regards,

• Please provide a complete minimal example that can be compiled and reproduce your problematic output, starting by \documentclass{article} (or whatever class you are using) and ending with \end{document} Jun 14 '20 at 3:30
• Stuff like that happens sometimes. You get a warning about it from TeX. Loading package microtype can help, just as rewriting the sentence will help. Jun 14 '20 at 3:48
• Tha package microtype indeed fixes most of the issues. Thank you very much. However, I still find issues in the references. Is there a package or maybe a special command to fix that ? Jun 15 '20 at 23:44
• In the third example, the word "showed" can't be hyphenated, so it's probably best to use sloppypar to reflow the paragraph (How to avoid using \sloppy document-wide to fix overfull \hbox problems?). The second paragraph would also succumb to the same technique, but there should also be a space before the \textit{p}-value, as there is before the same phrase earlier in the paragraph. Jun 16 '20 at 0:26
• I think you don't need tocbibind with this class? Jun 16 '20 at 3:08

Your macro \Cup creates the previous word impossible to use hyphenation, because box is appended immediately to the word. This complicates the paragraph breaking, so overfull \hboxes are more probably.
\def\Cup#1{\nobreak\textsuperscript{\cite{#1}}}

(or use \newcommand if you insist to the LaTeX notation:). The \nobreak macro inserts penalty between the word and the box constructed by \textsuperscript. The paragraph breaking algorithm accepts the previous word really as word in such case and hyphenation is allowed. So, segmentation can be divided by the rule seg-men-ta-tion if English hyphenation patterns are used.
• @Unic0 When you are using - inside a compound word then the whole is breakable only after the hyphen mark: deformable-/model. If you want to do hyphenation in the word before hyphen mark, put \nobreak before this character. I.e.: deformable\nobreak-model allows de-/formable-/model. You can insert explicitly hyphenation points too: de\-from\-able-model. Jun 16 '20 at 10:58
• @Unic0 Your example voc2012 is another issue. First of all you have to decide what to do: a) to move this unbreackable object to the next line and leave horrible spaces at the first line or b) to leave the rule about right justification or c) to reformulate the text. The c) is most recommended. If you decides to use a) then you can put (for example) \emergencystretch=4em as a setting of this paragraph. If you decides to use b), use \raggedright. Because you did not show your source, I do not show explicitly what to do in your source. Jun 16 '20 at 11:05