11

I have this word in my document:

--standard\_min\_confidence\_threshold\_for\_calling

It currently exceeds the page width. How can I make it start on the next line, so it doesn't exceed the page width? I should probably add that I'm new to tex.

  • 4
    after \_ you could add \linebreak[0] to allow a break or \- if you want it to add a - if it breaks the word. – David Carlisle Jan 22 '15 at 10:48
  • @david-carlisle So I have to insert a manual line break? And I have to modify that manual line break if the paragraph or sentence length changes? And I have to do this for all longs words? Oh dear... – tommy.carstensen Jan 22 '15 at 12:51
  • @tommy.carstensen No but given no context in your question all I could give is the lowest level answer. The commands I suggested are all conditional line breaks so they only take effect if needed, eg you could use \newcommand\myunder{\_\-} then use \myunder instead of \_ or presumably this is some programming identifier and you could redefine the command used to display the program fragments to allow linebreaking or lots of other possibilities. But your question needs to give a few clues – David Carlisle Jan 22 '15 at 14:06
  • @david-carlisle Sorry, I'm new to tex. I haven't reached a level yet, where I am able to ask good questions. Thanks for feedback. – tommy.carstensen Jan 22 '15 at 16:51
9

Edit: The microtype package probably also does what you want

\documentclass{article}
\usepackage{microtype}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ultricies volutpat rhoncus.
Fusce suscipit molestie rhoncus. Fusce nec tristique purus. Vestibulum ante ipsum primis in
faucibus orci luctus et ultrices posuere cubilia Curae; Phasellus mi leo, pharetra vitae
nunc vitae, imperdiet tincidunt dui. Cras placerat pulvinar massa, non tincidunt eros auctor ac.
standard\_min\_confidence\_threshold\_for\_{} Ut molestie convallis dui, a malesuada nunc
aliquet et. standard\_min\_confidence\_threshold\_for\_{} Aliquam rhoncus diam a nunc volutpat
mollis. Fusce mattis congue diam, in porttitor sem. Nam ut eros et urna consectetur sollicitudin.
Cras mollis pulvinar dui, porta auctor diam ultricies a. Morbi ultricies gravida nisl vel ornare.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Nunc accumsan scelerisque magna, vel venenatis metus aliquam ornare. Vivamus sed mollis ipsum.
\end{document}

gives

microtype

Maybe also sloppypar is what you want to put around your paragraphs with the long words. It will look ugly and manual breaking the long words is certainly better, though at least you cannot have too long lines anymore.

\documentclass{article}
\begin{document}
\begin{sloppypar}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ultricies volutpat rhoncus.
Fusce suscipit molestie rhoncus. Fusce nec tristique purus. Vestibulum ante ipsum primis in
faucibus orci luctus et ultrices posuere cubilia Curae; Phasellus mi leo, pharetra vitae
nunc vitae, imperdiet tincidunt dui. Cras placerat pulvinar massa, non tincidunt eros auctor ac.
standard\_min\_confidence\_threshold\_for\_{} Ut molestie convallis dui, a malesuada nunc
aliquet et. standard\_min\_confidence\_threshold\_for\_{} Aliquam rhoncus diam a nunc volutpat
mollis. Fusce mattis congue diam, in porttitor sem. Nam ut eros et urna consectetur sollicitudin.
Cras mollis pulvinar dui, porta auctor diam ultricies a. Morbi ultricies gravida nisl vel ornare.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Nunc accumsan scelerisque magna, vel venenatis metus aliquam ornare. Vivamus sed mollis ipsum.
\end{sloppypar}
\end{document}

Then you get

sloppypar

instead of this without sloppypar

nosloppypar

  • OK, now you added microtype. I will delete my answer. :-) – user11232 Jan 22 '15 at 14:14
  • It's ok. We probably edited it at the same time ;) – senegrom Jan 22 '15 at 14:15
8

I found the answer to my own question here: How can I make my text never go over the right margin by always hyphenating or breaking on word-boundaries?

The trick is to add \sloppy right after \begin{document}. That did the trick for me.

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.