Page LayoutHorizontal position control Grrr!

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
Julian_S_Moore
Posts: 72
Joined: Sun Nov 16, 2008 1:26 pm

Horizontal position control Grrr!

Post by Julian_S_Moore »

I am trying to precisely control the relative placement of words on several adjacent lines (see the output of the attached MWE) [NB the MWE is also the MWE for a separate question; this question refers to p1 of the output]

Problems:

\hphantom introduces additional paragraph spacing (see 2nd block of non-lipsum in MWE), so I wrote my own command \myphantom which measures the length of the text passed and inserts an \hspace of the required length; unfortunately, lines that should vertically align nicely still don't in an apparently random way (see 1st block of non-lipsum in MWE; all three lines are slightly different). To illustrate the problem the actually spacing has been commented out and the text that should be used to space surrounding text inserted.

Unavailable alternatives.
"Use white" - the text is going to be offset printed; if I specify "white", white will be printed, and if the paper isn't exactly white it will be visible.
\parshape - too complicated

Is there any thing wrong with what I've done? Is there a better way? Am I missing something about how LaTeX
Please can someone help me fix this... I have a few dozen such things to typeset and I can't get the book to the printers until I can do this... :(

Code: Select all

\documentclass[final,twoside,openright,showtrims,10pt]{memoir} % \documentclass[final,royalvopaper,twoside,openright,showtrims,10pt]{memoir}
\usepackage{calc, wrapfig}
\usepackage{xltxtra,fontspec,xunicode} 	% XeTeX stuff
\usepackage{ellipsis} 									% better ellipsis with \dots, \textellipsis
\renewcommand{\ellipsisgap}{0.1em}
\stockroyalvo
\settrimmedsize{663.3pt}{440pt}{*}
\setlength{\trimtop}{\stockheight}
\addtolength{\trimtop}{-\paperheight} % - \paperheight
\setlength{\trimedge}{\stockwidth} % \trimedge = \stockwidth
\addtolength{\trimedge}{-\paperwidth} % - \paperwidth
\settrims{0.5\trimtop}{\trimedge}
\settypeblocksize{537pt}{344pt}{*} % {344pt}{*} %{322.6pt}{*}

\setulmargins{56pt}{*}{*}
\setlrmargins{*}{*}{1}
\setheadfoot{36pt}{51pt}
\setheaderspaces{*}{12pt}{*}
\checkandfixthelayout
\setlength{\pdfpagewidth}{\paperwidth}
\setlength{\pdfpageheight}{\paperheight}

\usepackage{lipsum}
\usepackage{ellipsis}
\newenvironment{narrative}%
	{\setlength{\parindent}{12pt} \setlength{\parskip}{0pt}}
	{}

\newlength{\tpad}
\newlength{\hpad}
\newcommand{\myphantom}[1]{
%	\settowidth{\hpad}{#1}\hspace{\hpad}
#1}
\newcommand{\lrcentrepad}[1]{
% calculate the room left remaining on a line if #1 were placed and divide it by two for assignment to left & right skip
		\settowidth{\tpad}{#1}
		\addtolength{\tpad}{-\textwidth}
		\setlength{\tpad}{0.5\tpad}
		\setlength{\tpad}{-1\tpad}
	}
	
\begin{document}
	\begin{narrative}
		ILLUSTRATION OF HORIZONTAL WORD PLACEMENT PROBLEMS \par\par\par % why aren't these \par's having any effect?
		\lipsum[1]\par
		\lrcentrepad{He's wise\dots{}.~He's old!~He is a stranger.~A traveller?~He is a fool!}
		{\vspace{6pt}\centering{}He's~wise\dots{}.~\myphantom{He's~old!~He~is~a~stranger.~A~traveller?}~He~is~a~fool!\par\vspace{6pt}}
		{\centering{}\myphantom{He's~wise\dots{}.}~He's~old!~\myphantom{He~is~a~stranger.}~A~traveller?~\myphantom{He~is~a~fool!}\par\vspace{6pt}}
		{\centering{}\myphantom{He's~wise\dots{}.~He's~old!~}He~is~a~stranger.~\myphantom{A~traveller?~He~is~a~fool!}\par\vspace{6pt}}
		\lipsum[2]
		\lrcentrepad{He's wise\dots{}.~He's old!~He is a stranger.~A traveller?~He is a fool!}
		{\vspace{6pt}\centering{}He's~wise\dots{}.~\hphantom{He's~old!~He~is~a~stranger.~A~traveller?}~He~is~a~fool!\par\vspace{6pt}}
		{\centering{}\hphantom{He's~wise\dots{}.}~He's~old!~\hphantom{He~is~a~stranger.}~A~traveller?~\hphantom{He~is~a~fool!}\par\vspace{6pt}}
		{\centering{}\hphantom{He's~wise\dots{}.~He's~old!~}He~is~a~stranger.~\hphantom{A~traveller?~He~is~a~fool!}\par\vspace{6pt}}
		\lipsum[3] \par
		\newpage
		ILLUSTRATION OF CENTERING AND LEFT/RIGHTSKIP PROBLEMS \par \par
		{\leftskip=36pt\rightskip=36pt \lipsum[4] \par} %this is appropriately narrowed
		{\centering \lipsum[5] \par}% this is appropriately centered
		{\centering \leftskip=36pt\rightskip=36pt \lipsum[6]\par}%centering and left/rightskip don't work together?
		\begin{center}% doesn't make any different if I use an environment
			\leftskip=36pt\rightskip=36pt \lipsum[7]\par
		\end{center}
		\setlength{\hpad}{36pt}
		\begin{center}% not a problem with the way I was setting left/rightskip
			\setlength{\leftskip}{\hpad} \setlength{\rightskip}{\hpad}\lipsum[8]\par
		\end{center}
	\end{narrative}
\end{document}

Recommended reading 2024:

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

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

Julian_S_Moore
Posts: 72
Joined: Sun Nov 16, 2008 1:26 pm

Re: Horizontal position control Grrr!

Post by Julian_S_Moore »

As noted in another post, with thanks to Enrico Gregorio and Lars Madsen in comp.text.tex the following info is critical

1/ \phantom (or similar) TeX commands, at the beginning of a line must be preceded by \leavevmode (LEAVE-VMODE; a LaTeX command) or whatever the TeX equivalent is.
2/ \flushleft \flushright \center all introduce extra vertical spacing because they are "environments" (& related to lists)
3/ For simple alignment changes without altering anything else use \raggedright, \raggedleft, \centering respectively.

Position control has been restored... sanity adjustment pending.
Post Reply