Page LayoutMargin complexities

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Erica
Posts: 6
Joined: Tue Feb 21, 2012 2:56 pm

Margin complexities

Post by Erica »

Trying to format a document, article class, oneside, using \usepackage{txfonts} and \ttfamily to create a narrow courier font.

Code: Select all

\usepackage{geometry}
\geometry{a4paper} 
are also in my preamble.

I would like my document margins to be in the region of 1in on the right hand side.

The document formats fine on the left and appears to work fine for the right hand side until I add in an item environment at which point the right hand margins go to hell (too wide and too ragged).

Have tried tinkering with the preamble (adding in specifics) and have tried adding in a \newgeometry command with specific dimensions in the item environment and about a hundred other vague tinkerings but to no avail.

Am I missing something obvious? Is the problem maybe created by trying to change the font? I have spent the last two days on this and can no longer see the wood for the trees :?

Any ideas?
Last edited by Stefan Kottwitz on Tue Feb 21, 2012 4:52 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Margin complexities

Post by Stefan Kottwitz »

A typewriter font is ragged by default, as every character has the same width, also the space between words has the same width, and hyphenation may be disabled. You could enable it for example by writing

Code: Select all

\hyphenchar\font=`\-
directly after \ttfamily.
With some effort, even full justification can be achieved with a typewriter font.

Stefan
LaTeX.org admin
Erica
Posts: 6
Joined: Tue Feb 21, 2012 2:56 pm

Re: Margin complexities

Post by Erica »

Thank you for that Stefan; now that you point it out, it makes perfect sense and ragged I can certainly live with now that I look at it again.

However, it still leaves me with a right hand margin roaming far too wide for my liking; it has left the headers and footers sitting a good half inch behind. Is there any means of manipulating this margin into line, ragged or otherwise?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Re: Margin complexities

Post by Stefan Kottwitz »

Is a Courier like font really a requirement? Usually such a font is hard to read. In contrast to the past days of the typerwriter machines, we commonly use proportional fonts today. Non-proportional (typewriter) fonts are commonly used for code listings, where character columns and indentation can be important.

I would simply switch to a proportional font and the problems with overlapping into the margings may be solved thanks to LaTeX's text justification and hyphenation.

Stefan
LaTeX.org admin
Erica
Posts: 6
Joined: Tue Feb 21, 2012 2:56 pm

Re: Margin complexities

Post by Erica »

Unfortunately, stylistically, the font is non-negotiable (and I realised it might be the font that was causing the problem). The slightly narrower version of courier provided by the \txfonts package looks pretty good and reads quite well. If needs be, I will live with my roaming right margin, but I would so prefer not to, but if hyphenating might cure some of the worst of it, I will give that a go and let you know how I get on.

Thanks
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Margin complexities

Post by Stefan Kottwitz »

Here's an example how you could get a straight right margin even with txfonts typewriter font.

Code: Select all

\documentclass{article}
\usepackage{txfonts}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{everysel}
\renewcommand*\familydefault{\ttdefault}
\EverySelectfont{%
  \fontdimen2\font=0.4em% interword space
  \fontdimen3\font=0.2em% interword stretch
  \fontdimen4\font=0.1em% interword shrink
  \fontdimen7\font=0.1em% extra space
  \hyphenchar\font=`\-% to allow hyphenation
}
\begin{document}
\section{Test}
\blindtext
\begin{itemize}
  \item \blindtext
\end{itemize}
\end{document}
typewriter-justified.png
typewriter-justified.png (29.74 KiB) Viewed 12834 times
I posted such a solution on my blog a while ago: Full justification with typewriter font.

Stefan
LaTeX.org admin
Erica
Posts: 6
Joined: Tue Feb 21, 2012 2:56 pm

Re: Margin complexities

Post by Erica »

Thanks for that; have added in the coding and it is now hyphenating beautifully; still ragged though and still wandering over the outer edge of the right hand margin - will look at it again tomorrow and see if there is something I have missed; if not, I may just have to let it ramble.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Margin complexities

Post by Stefan Kottwitz »

Note, I used \EverySelectfont, otherwise the effect would go away on font changes.

Stefan
LaTeX.org admin
Erica
Posts: 6
Joined: Tue Feb 21, 2012 2:56 pm

Re: Margin complexities

Post by Erica »

Thank you Stefan. I maybe being a bit slow here - I have \EverySelectfont in my preamble but needed to close the argument brackets in order to get the document to typeset; the argument is empty - should I be doing something more with it? I haven't really fully understood its purpose I don't think. :?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Margin complexities

Post by Stefan Kottwitz »

The argument to \EverySelectfont is in the next lines, as it's long and consists of several commands. I indented it to make it better visible.

Code: Select all

\EverySelectfont{%
  \fontdimen2\font=0.4em% interword space
  \fontdimen3\font=0.2em% interword stretch
  \fontdimen4\font=0.1em% interword shrink
  \fontdimen7\font=0.1em% extra space
  \hyphenchar\font=`\-% to allow hyphenation
}
Stefan
LaTeX.org admin
Post Reply