Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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).

share|improve this question

1 Answer 1

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.