Text FormattingText not abiding by the right margin set with geometry

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
pingo
Posts: 3
Joined: Fri Dec 24, 2010 7:43 pm

Text not abiding by the right margin set with geometry

Post by pingo »

Hello everyone.

I'm a newbie with Latex and on these forums so please be patient. I have tried Latex just recently because it seems really great for writing reports. Everything is great but I have a problem I can't seem to figure out.

Maybe I don't understand something, but 95% of my document is abiding by the margins I specified with the geometry package. I have attached a sample tex code with a page that has out of margin/border text and also a screenshot of the resulting document.

Please tell me what I am doing wrong.

Code: Select all

\documentclass[12pt,a4paper,openany]{book}

\usepackage{fancyhdr}
\usepackage{graphicx,epsfig}
\usepackage[slovene]{babel} 
\usepackage[cp1250]{inputenc}

\usepackage{graphics}
\usepackage{float}

\usepackage{listings}
\lstset{numbers=none,breaklines=true}

\catcode`\"=13
	\def"#1{\v #1}
	
\usepackage[top=2cm, bottom=3cm, left=2cm, right=2cm]{geometry} 

\pagestyle{fancy}
\fancyfoot{} 
\fancyhead{} 
\fancyhead[LE, OR]{\thepage}

\renewcommand{\headrulewidth}{0.0pt} 
\renewcommand{\footrulewidth}{0.0pt} 

%********************************************

\thispagestyle{empty}
\begin{document}
\setlength{\parindent}{0in} 

\chapter{LITERATURA IN VIRI}
\thispagestyle{fancy}

[1] (2011) Dokumentacija knjižnice IT Hit WebDAV .Net Server Engine. Dostopno na: http://www.webdavsystem.com/server.

[2] (2011) Splošno o protokolu WebDAV. Dostopno na: http://en.wikipedia.org/wiki/WebDAV.

[3] (2011) Protokol WebDav. Dostopno na: http://www.webdav.org/.

[4] (2011) RFC 2518 (HTTP Extensions for Distributed Authoring -- WEBDAV). Dostopno na: http://www.ietf.org/rfc/rfc2518.txt.

[5] (2011) RFC 3253 (Versioning Extensions to WebDAV). Dostopno na: http://www.ietf.org/rfc/rfc3253.txt.

[6] (2011) Microsoft .NET Framework 3.5 System.Net.HttpListener dokumentacija. Dostopno na: http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx.
\end{document}

Image
Last edited by pingo on Wed Jan 12, 2011 6:16 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Text not abiding by the right margin set with geometry

Post by meho_r »

Hi. It's not a geometry package issue. TeX simply cannot find an optimal place to break the line because of long links so it leaves that decision to the user. Try loading url package (or hyperref) and use \url{} command for links.

Code: Select all

\documentclass[12pt,a4paper,openany,draft]{book}

\usepackage{fancyhdr}
\usepackage{graphicx,epsfig}
\usepackage[slovene]{babel} 
\usepackage[cp1250]{inputenc}

\usepackage{graphics}
\usepackage{float}

\usepackage{listings}
\lstset{numbers=none,breaklines=true}

\catcode`\"=13
   \def"#1{\v #1}
   
\usepackage[top=2cm, bottom=3cm, left=2cm, right=2cm]{geometry} 

\pagestyle{fancy}
\fancyfoot{} 
\fancyhead{} 
\fancyhead[LE, OR]{\thepage}

\renewcommand{\headrulewidth}{0.0pt} 
\renewcommand{\footrulewidth}{0.0pt} 

%********************************************

\thispagestyle{empty}

\usepackage{url}

\begin{document}
\setlength{\parindent}{0in} 

\chapter{LITERATURA IN VIRI}
\thispagestyle{fancy}

[1] (2011) Dokumentacija knjižnice IT Hit WebDAV .Net Server Engine. Dostopno na: \url{http://www.webdavsystem.com/server}.

[2] (2011) Splošno o protokolu WebDAV. Dostopno na: \url{http://en.wikipedia.org/wiki/WebDAV}.

[3] (2011) Protokol WebDav. Dostopno na: \url{http://www.webdav.org/}.

[4] (2011) RFC 2518 (HTTP Extensions for Distributed Authoring -- WEBDAV). Dostopno na: \url{http://www.ietf.org/rfc/rfc2518.txt}.

[5] (2011) RFC 3253 (Versioning Extensions to WebDAV). Dostopno na: \url{http://www.ietf.org/rfc/rfc3253.txt}.

[6] (2011) Microsoft .NET Framework 3.5 System.Net.HttpListener dokumentacija. Dostopno na: \url{http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx}.
\end{document}
Apart from hyperlinks, in case you got some text going into the margin, there are couple of solutions for that:

1. Define custom hyphenation points using \- (e.g. hy\-phen\-a\-ti\-on). Now TeX will hyphenate the word on one of specified places.

2. Use \sloppy command. You may put this command before the paragraph which contains problematic text to allow larger spacing between words. To get things back to "normal", use \fussy command before the next paragraph.

3. You can use \linebreak command to insert manual line breaks. However, this is usually a bad idea, so try to avoid it as much as possible.
pingo
Posts: 3
Joined: Fri Dec 24, 2010 7:43 pm

Re: Text not abiding by the right margin set with geometry

Post by pingo »

Thank you for the help. I used your suggestion with \sloppy and \fussy since I prefer the links not to be broken up and formatted differently than the text.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Text not abiding by the right margin set with geometry

Post by localghost »

Now that the problem seems to be solved, please be so kind and mark the topic accordingly as clearly written in Section 3 of the Board Rules (to be read before posting). Please keep that in mind for the future so that further reminders will not be necessary.


Best regards and welcome to the board
Thorsten
pingo
Posts: 3
Joined: Fri Dec 24, 2010 7:43 pm

Re: Text not abiding by the right margin set with geometry

Post by pingo »

I'm sorry. I did try to mark it, but was unable to find this feature anywhere and thought that the moderators did that. By following your link I did find the instructions, thank you.
Post Reply