From de306ceccf9edccf08c890742f124b157444b679 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sat, 30 Sep 2023 16:49:42 +0200 Subject: add new ruletoend command drawing a rule for the remaining hsize --- latex/common.tex | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/latex/common.tex b/latex/common.tex index 55f6c2b6..031af2c4 100644 --- a/latex/common.tex +++ b/latex/common.tex @@ -117,3 +117,36 @@ \DeclarePairedDelimiter\abs{\lvert}{\rvert}% \newcommand{\dist}[1]{\abs{\overline{#1}}} + +% Commands to determine the remaining hsize of a line +% See: https://tex.stackexchange.com/questions/17349/is-there-a-way-to-measure-the-remaining-space-of-a-line-of-text +\newcommand{\currentsidemargin}{% + \ifodd\value{page}% + \oddsidemargin% + \else% + \evensidemargin% + \fi% +} + +\newlength{\whatsleft} + +\newcommand{\measureremainder}[1]{% +\begin{tikzpicture}[overlay,remember picture] + % Helper nodes + \path (current page.north west) ++(\hoffset, -\voffset) + node[anchor=north west, shape=rectangle, inner sep=0, minimum width=\paperwidth, minimum height=\paperheight] + (pagearea) {}; + + + \path (pagearea.north west) ++(1in+\currentsidemargin,-1in-\topmargin-\headheight-\headsep) + node[anchor=north west, shape=rectangle, inner sep=0, minimum width=\textwidth, minimum height=\textheight] + (textarea) {}; + + % Measure distance to right text border + \path let \p0 = (0,0), \p1 = (textarea.east) in + [/utils/exec={\pgfmathsetlength#1{\x1-\x0}\global#1=#1}]; + +\end{tikzpicture}% +} + +\newcommand{\ruletoend}[1]{\measureremainder{\whatsleft}\rule{\whatsleft}{#1}} -- cgit v1.2.3