Skip to content

Instantly share code, notes, and snippets.

@dohyunkim
Last active January 4, 2016 15:59
Show Gist options
  • Select an option

  • Save dohyunkim/8644216 to your computer and use it in GitHub Desktop.

Select an option

Save dohyunkim/8644216 to your computer and use it in GitHub Desktop.
zref + mplib: a proof of concept
\documentclass[a4paper]{article}
\usepackage{luamplib, zref-savepos, atbegshi, picture}
\begin{document}
\AtBeginShipoutNext{\AtBeginShipoutUpperLeft{%
\put(0,-\paperheight){%
\begin{mplibcode}
beginfig(0);
x0 := \mpdim{\zposx{z0x} sp};
y0 := \mpdim{\zposy{z0y} sp};
x1 := \mpdim{\zposx{z1x} sp};
y1 := \mpdim{\zposy{z1y} sp};
drawarrow z0{dir 45} .. {dir 45}z1 withcolor red;
setbounds currentpicture to
origin--(0,\mpdim{\paperwidth})--
(\mpdim{\paperwidth},\mpdim{\paperheight})--
(\mpdim{\paperheight},0)--cycle;
endfig;
\end{mplibcode}}}}
\fbox{This}\zsavepos{z0x}\vadjust pre{\zsavepos{z0y}} is a test line.
This is a test line.
This is a test line.
This is a test line.
This is a test line.
This is a test line.
This is a test line.
This is a test line.
This is a test line.
This is a test line.
This is a test line.
This is a test \zsavepos{z1x}\vadjust{\zsavepos{z1y}}\fbox{line}.
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment