4

Why \emph ignores the page margin? How can I fix it by setting the word in emph to a new line? See the example below:

Example

EDIT: The second line of the text is too long. I don't want "edu.kit.sdq.modeljoin.compliance.model" to be separated, but to be placed on a new line, so that the page margins are correct.

EDIT 2: MWE:

\documentclass[11pt, a4paper]{article}

\begin{document}
mdskam saskksk smdlakm dklsa mldk dlksam lkdsam sksksk \emph{de.de.de.de.de.de.de.de.de.de} dsamkld samkl samkl dsamkl dsamkl mdslkam dlskam dklsam kldasm dklsamlkd smalk maslkmdsalkas mnsbh ds dsm fndjk sdfdslkm dsmk ldsm klfdsm fklds 
\end{document}
6
  • Where should TeX break that "word"?
    – Werner
    Commented May 29, 2013 at 14:16
  • Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – jub0bs
    Commented May 29, 2013 at 14:17
  • You could use the url package to help with breaking of such identifiers Commented May 29, 2013 at 14:22
  • @AndrewSwann I guess that's the solution but since no MWE is given, whether "edu.kit.sdk..." is a URL remains unclear...
    – jub0bs
    Commented May 29, 2013 at 14:29
  • 1
    It's not \emph (as you will see if you remove it). If it's just one case, either add manual hyphenation or put an \allowbreak at suitable points in the package name. Commented May 29, 2013 at 14:41

2 Answers 2

5
\documentclass[11pt, a4paper]{article}

\begin{document}\sloppy
                 %%%%%%
mdskam saskksk smdlakm dklsa mldk dlksam lkdsam sksksk \emph{de.de.de.de.de.de.de.de.de.de} dsamkld samkl samkl dsamkl dsamkl mdslkam dlskam dklsam kldasm dklsamlkd smalk maslkmdsalkas mnsbh ds dsm fndjk sdfdslkm dsmk ldsm klfdsm fklds 
\end{document}
14

this has nothing to do with \emph. the string that isn't broken has no spaces in it, and it's full of punctuation, so tex has no idea where to break it -- the hyphenation routine simply doesn't work in this situation.

the easiest way to get this to break is to use the url package, and use the command \url{xxx.xxx.xxx} to apply a different set of breaking rules. even if this isn't really a url, the same breaking mechanism should be applied.

edit: the OP doesn't want to break the "unbreakable" string. there are a few ways of avoiding such a break:

  • at the beginning of the paragraph that contains the string, add \begin{sloppypar}, and add \end{sloppypar} at the end of the paragraph. this will result in the offending string being moved to the next line, leaving the previous line with unpleasantly wide spaces, and the remainder of the paragraph probably with uneven spacing. this technique will limit the spacing effect to that one paragraph, unlike the suggestion proposed by david carlisle, which will affect the whole document.

  • just decide to leave the line before that string short, and insert \\ right before it. this will have no adverse spacing effects on the rest of the paragraph, and in the circumstances, will probably produce a more attractive result.

  • set the string on a line by itself, perhaps treating it as an "equation": \[\text{...}\]. (\text requires use of the amsmath package.)

  • rephrase the paragraph.

all of these approaches ignore the possibility that the "unbreakable" string may be longer than the document's text width, a situation that is not unknown.

2
  • I don't want to break the xxx.xxx.xxx. I want to move it to a new line as it is. Is it possible?
    – aphex
    Commented May 29, 2013 at 14:50
  • 2
    Yes, it is. But it gives you either a ridiculous underfull box or empty space. It would be better to rephrase the paragraph so that xxx.xxx.xxx.xxx does not appear at the end of a line. Commented May 29, 2013 at 14:53

You must log in to answer this question.

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