I want to position certain elements exactly in the corners of my page. With research, textblock
seemed to be what I needed.
Here is a working example of that, before wrapfigure
caused problems:
\documentclass[a4paper,10pt,openany,twoside]{scrbook}
\usepackage{wrapfig}
\usepackage[absolute]{textpos}
\setlength{\TPHorizModule}{\paperwidth}
\setlength{\TPVertModule}{\paperheight}
\newcommand{\myblocks}
{
\begin{textblock}{1}[0,-1](0,0)
{\huge LEFT LEFT LEFT}
\end{textblock}
\begin{flushright}
\begin{textblock}{1}[0,-1](0,0)
{\huge RIGHT RIGHT RIGHT}
\end{textblock}
\end{flushright}
}
\newcommand{\mybox}
{
\begin{wrapfigure}{o}{0.3\textwidth}
\subsection*{TEST}
TEST WRAP FIGURE
\begin{tabular}{|lrl|}
\hline
a & b & c \\
a & b & c \\
a & b & c \\
\hline
\end{tabular}
\end{wrapfigure}
}
\begin{document}
\chapter{blank page}
\chapter{Alpha}
%\mybox
\myblocks
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
\chapter{Beta}
%\mybox
\myblocks
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
\end{document}
Here is how it renders. This is exactly as intended. (There is extra vertical padding due to the -1
y-coordinate argument to the textblock environment
, but otherwise the LEFT
and RIGHT
boxes are tightly in their respective corners.)
If we comment out the \myblocks
invocations and uncomment \mybox
...
\chapter{Alpha}
\mybox
%\myblocks
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
\chapter{Beta}
\mybox
%\myblocks
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
Then these float-out tables also behave as intended, with text wrapping around them.
However, if I uncomment both of these, they both break.
\chapter{Alpha}
\mybox
\myblocks
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
\chapter{Beta}
\mybox
\myblocks
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
Here's how it renders:
There are multiple problems:
there is extra whitespace to the left of
LEFT
on both pages, it needs to be tight,the float-out table for "Alpha" is entirely missing,
the float-out table for "Beta" is above the section heading, tight to the right-hand margin (as if it's inside the
textblock
)
I tried reversing the order of \myblock
and \mybox
invocations:
\chapter{Alpha}
\myblocks
\mybox
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
\chapter{Beta}
\myblocks
\mybox
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
This also renders incorrectly:
The LEFT
whitespace is gone but now neither table floats out to the edge nor lets the "lorem ipsum" text wrap around it. Moreover there is a warning in the compiler output:
Package wrapfig Warning: wrapfigure used inside a conflicting environment on in put line 43.
Package wrapfig Warning: Stationary wrapfigure forced to float on input line 44
I don't understand these messages.
The intended end goal for this is that the "LEFT" and "RIGHT" placeholders will be generated to conform to the section heading. In other words, I will end up write something like this
\newcommand{\mysection}[1]
{
\chapter{\gettitle{#1}}
\drawcornerfeatures{#1}
}
\mysection{Alpha}
\begin{wrapfigure}{o}{0.3\textwidth}
...
\end{wrapfigure}
Lorem ipsum ...
This means the code which generates the "LEFT" and "RIGHT" features must come before the float-out table or the lorem ipsum text. In other words, the warning-emitting final example above is the correct order of events, and it although it draws the corners correctly, I need the tables to float out.
How can I get both of these effects to work together?