1

Apologies: I want to violate the most basic prescriptions of sane typography. Have a bag ready. It's the lesser of evils.

Say, I have a book, with margins of 0.5 inches on the spine and 1 inch on the edge. I have a bunch of tabulars that may exceed the \textwidth, rarely more than 5em. I know I should break the tabulars, but this would be very difficult. (I do know I can already shrink the tabular horizontal spacing and the font sizing.)

The standard latex behavior is to push my (otherwise centered tabular) text over the right text edge. Instead, I would like to specify how strong my tabular that exceeds the textwidth should push left vs right into the odd-side and the even-side margins. For example, if I have 0.5 and 1 inch margins, I may want to push two points over the right margin for every point I push over the left margin. This would be on an odd-numbered page, with the opposite for an even numbered page.

This may be too much to ask for, but I can imagine that this could be of interest to more folks than just myself.

4
  • 1
    For example package scrextend provides an environment addmargin that can be used. There are other packages with similar features. You also could use negative space, e.g., \hspace*{-1in} etc.
    – cabohah
    Commented Aug 2 at 13:20
  • There is also landscape and sidewaystable. While overlapping to the rught is the default, it also generates a warning (overfull \hbox). \makebox[\textwidth][c]{...} overlaps equally on both sides (no warning). Commented Aug 2 at 13:39
  • 2
    changepage provides an environment which specifically does this (and also environments to change the page geometry more radically). obviously prefer scrextend if using a koma class, but changepage works well for me with standard classes.
    – cfr
    Commented Aug 2 at 13:40
  • 1
    @JohnKormylo \makebox will mean you won't get warnings however much it exceeds the width by and can't be used with long tabulars. changepage's environment I like because I'll still get those warnings etc.
    – cfr
    Commented Aug 2 at 13:42

1 Answer 1

2

Just the last of these lines is over-full. The first three are centred in the text block, the later ones hang three times as much into the right margin as the left.

enter image description here

\documentclass{article}

\newcommand\x[1]{%
  {\parfillskip=0pt
    \par \noindent X\dotfill
    {\ttfamily\detokenize{#1}}%
    \dotfill X%
    \par\noindent\nobreak\hspace{0pt plus \textwidth minus 20pt}%
    \rule{#1}{2pt}%
    \nobreak\hspace{0pt plus \textwidth minus 60pt}\mbox{}\par}%
}

\begin{document}

\noindent X\dotfill X

\x{.5\textwidth}

\x{.9\textwidth}

\x{\textwidth}

\x{1.05\textwidth}

\x{1.1\textwidth}

\x{1.15\textwidth}

\x{1.2\textwidth}

\x{1.3\textwidth} % over full


\end{document}
4
  • thx, as always. Can this be different for even and odd pages, to reach less into the spine?
    – ivo Welch
    Commented yesterday
  • @ivoWelch well you can easily make the 20pt and 60pt \ifodd\value{page}20pt\else60pt\fi for one and \ifodd\value{page}60pt\else20pt\fi for the other although page value isn't guaranteed unless you are after a \clearpage` or you use some \label/\pageref` to get the real page number Commented yesterday
  • Thanks. I should be able to get this going! :-). I wonder why there is not an \ifodd* version that places label and pageref so that the value is guaranteed. (What good is a potentially false \ifodd?)
    – ivo Welch
    Commented 8 hours ago
  • \ifthenelse makes \pageref testable (and makes it 0 on the first run rather than make a warning) for this reason. The testing with \ifodd is not false it is just that you need to be careful when you test. the page number changes throughout the document and the value when you do the test is odd or even but that may not be what you meant to test for. For example if you write a long 5 page paragraph, the page number does not change until after the paragraph is broken in to lines and the lines broken in to pages. So when all macros are expanded the page number is 1 and \ifodd is true. Commented 8 hours ago

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.