As a follow-up question to this: How to typeset a critical apparatus like the commented "Mein Kampf" edition?
Since the packages that came up didn't exactly do what I wanted, I came up with this code:
\documentclass{article}
\newlength{\commentlength}
\newlength{\thiscommentxstart}
\newlength{\thiscommentxend}
\newlength{\commentstartx}
\newlength{\commentstarty}
\newlength{\thisboxstartx}
\newlength{\thisboxendx}
\newlength{\thisboxstarty}
\newlength{\thisboxendy}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{xcolor}
\newcounter{comments}
\setcounter{comments}{1}
\usepackage{lengthconvert}
\usepackage{zref-savepos}
\usepackage[absolute,overlay]{textpos}
\usepackage{calc}
\setlength{\TPHorizModule}{\textwidth}
\setlength{\TPVertModule}{\textheight}
\textblockorigin{0mm}{0mm}
\newcommand*{\currpos}[1]{%
\zsavepos{#1}%
}
\newcommand{\mycomment}[4]{%
\currpos{#1}%
%
\setlength{\thisboxstartx}{\zposx{#1}sp}%
\setlength{\thisboxstarty}{\zposy{#1}sp}%
\setlength{\thisboxendx}{\zposx{#2}sp}%
\setlength{\thisboxendy}{\zposy{#2}sp}%
%
\setlength{\thiscommentxstart}{\thisboxstartx}%
\setlength{\thiscommentxend}{\thisboxendx}%
\setlength{\commentlength}{\thisboxendx-\thisboxstartx-\marginparwidth}%
\if\ifnum\thiscommentxstart<\thiscommentxend%
\setlength{\commentlength}{\thisboxstartx-\marginparwidth}%
\fi%
\setlength{\commentstartx}{\thisboxstartx}%
\setlength{\commentstarty}{(\paperheight-\thisboxstarty)+\voffset-0.1in}%
\textbf{#3}\currpos{#2}%
\vadjust{\begin{textblock*}{\commentlength}(\commentstartx,\commentstarty)\noindent%
\textcolor{red}{#4}%
\end{textblock*}}%
}
\begin{document}
das hier ist fließtext um \mycomment{label}{labelende}{einen relativ kurzen text und seine textbox}{kommentare können durchau auch mal länger sein als der kommentierte text, müssen sie aber nicht} herum. danach folgt weiterer unkommentierter text.
\vspace{10em}
das hier ist weiterer fließtext um \mycomment{labelzwei}{labelzweiende}{einen kurzen und seine textbox}{kommentar 2 ist kürzer als kommentar 1} herum. danach folgt weiterer unkommentierter text.
\end{document}
This creates a document like this:
This is kind of similiar to what I want. I now only need two more things to do:
- Automatically create an empty page after every page
- Move the textblock* to that page.
I couldn't find any way to get LaTeX to write text on page n + 1, whilst it still being at page n. Do I have to write this in the aux file somehow? Or is there anything else possible to achieve this?
If this is done, my goal would be achieved. Can anybody here help me? As I've said, I couldn't find information both of these problems.