I use custom 1 inch margins for most of my homework but for some reason LyX likes to ignore the margins sometimes, for example:

enter image description here

I don't know why it keeps doing this it happens in a lot of my homework, any ideas?

  • 4
    Are you using the typewriter font family as default? I don't think TeX hyphenates text in that family, which can cause the text to run into the margin some times. (Why it happens with 'of our' I don't know.) Could you make a minimal example, i.e. a document with the smallest amount of text and customisations that still show the problem, and then edit your question to include the contents of that .lyx file and/or the exported LaTeX source code? – Torbjørn T. Oct 12 '13 at 6:21
  • 1
    In addition to @TorbjørnT.'s remarks, note that in typewriter type the interword space has no flexibility; the lines with math can be adjusted, but not the line with “of our” that has no math in it. – egreg Oct 12 '13 at 10:29
  • @TorbjørnT. Yes I am using typewriter font family with 12pt as my default font. I ditched the typewriter font an the 12pt font and everything looks well for now. I have a lot of homework to do this week so, if I have it happen again I will edit this question with a more minimal example. Thanks a lot for your help! – JimmyJackson Oct 12 '13 at 17:49
  • I propose that @TorbjørnT. posts an answer for this question. If you have another question, ask another question (and feel free to reference this question). – scottkosty Oct 12 '13 at 20:42
  • @scottkosty i agree, TorbjørnT comment did indeed solve my problem. – JimmyJackson Oct 12 '13 at 21:09

In this case the problem is that the Typewriter family is set as the default font family in Document --> Settings --> Fonts. TeX does not hyphenate words set with \ttfamily, and (mentioned by egreg) the inter-word spacing has no flexibility. This causes some words to stick out into the right margin. Changing the default font family to Roman (or Default) should fix this.


Try adding \sloppy to the beginning of your document.

  • This solved my own problem (\lstinline overrunning margins even with \raggedright). My complete solution was \usepackage{ragged2e} \RaggedRight\sloppy — goodbye unreadable text! – Quuxplusone Jul 25 '17 at 8:31

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.