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: unrespected_margin

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

\documentclass[12pt, english, onehalfspacing, headsepline]{MastersDoctoralThesis}
        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.



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)
% This template was downloaded from:
% 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/)
% Template license:
% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)

The other issues seem similar:

misalignemnt_II misalignemnt_III

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{mathpazo} % Use the Palatino font by default
\usepackage[font=singlespacing, font=small]{caption}
\usepackage{amsfonts, amsmath, amsthm, amssymb}

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.



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}
    – hesham
    Jun 14 '20 at 3:30
  • 2
    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.
    – Johannes_B
    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 ?
    – Unic0
    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?
    – Johannes_B
    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.



(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.

  • It works, indeed, I get overall more breaks now. However, I still can see some odd overflow out of margin at various places. Is there other way to correct these issues ? [update in the main question]
    – Unic0
    Jun 15 '20 at 23:22
  • 1
    @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.
    – wipet
    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.
    – wipet
    Jun 16 '20 at 11:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.