2

I have chapters (using the standard "report" class), and I would like to place a frame of text - which gives succinct meta-details on the chapter - at the top of the first page of the chapter.

What I have succeeded in doing do far is this:

enter image description here

My problem is that the only way I've managed to do things is with TikZ absolute positioning (I know about various packages, such as textpos, and I have not been able to get them to work satisfyingly).

What is lacking with solution is that I have not been able to precisely control where the frame is - or rather, I must specify too precisely where it must be (using absolute coordinates), whereas I would just like it to be exactly vertically aligned with the body of the text, and just have to give the absolute distance from the top.

I.e., something like:

\myboxedtext{1cm}{Text}

puts a framed box of text of the same width as the body of the text, and aligned with the body of the text, at 1cm from the top.

How could I do that? I have tried combining raisebox with pagetotal but to no avail...

EDIT: and I'd like to avoid using TikZ (or any unstable solution that requires I compile multiple times).

1 Answer 1

2

You can easily achieve what you want using tikz placing a node at current page.north with anchor=north and a yshift specified through an argument, controlling the vertical separation between the top border of the page and the top border of the node:

\documentclass[openany]{report}
\usepackage{tikz}
\usepackage{lipsum}

\newcommand\ChapterPrecis[2]{%
\begin{tikzpicture}[remember picture,overlay]
\node[anchor=north,draw,yshift=-#1] at (current page.north) {\parbox[t][3cm][c]{\linewidth}{#2}};
\end{tikzpicture}%
}

\begin{document}

\chapter{Test Chapter One}
\ChapterPrecis{1cm}{\lipsum[2]}
\lipsum[1-3]
\chapter{Test Chapter Two}
\ChapterPrecis{2cm}{\lipsum[2]}
\lipsum[1-3]

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .