TeX - LaTeX Asked on February 19, 2021
Zref does calculate the coordinate of north west of P1 (= baseline of "some text"), which in my case is approx (50mm, 274mm)
so if i make "uuuuuu" in Textblock with the same coordinates, it also puts "uuuuu" in north west. Then the baseline is not the same. The result seems like it shiftet.
My simple question: how can i force zref and textblock operate with the baseline and not north west?
documentclass[12pt,oneside,german]{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{xcolor}
usepackage[paperwidth=210 mm,paperheight=297 mm,left=50mm,top=20mm]{geometry}
usepackage[absolute,overlay]{textpos}
usepackage{zref-abspos}
usepackage{tcolorbox}
%tcbuselibrary{skins,breakable}
topskip=0pt
setlength{parindent}{0pt} % = global noindent
renewcommand{baselinestretch}{1.3}
newcommand{myfunction}[1]{%
zsavepos{P1}% Store the current position as #1
#1%
}
makeatletter
newcommanddimtomm[1]{%
strip@ptdimexpr 0.351459804dimexpr#1relaxrelax
}
makeatother
textblockorigin{0mm}{297mm}
begin{document}
some text
myfunction{P1}
vspace*{5mm}
The coordinate of P1 is: (dimtomm{thedimexpr zposx{P1}sp relax} mm,dimtomm{thedimexpr zposy{P1}sp relax} mm)
begin{textblock*}{thetextwidth}(49.9994mm,-274.40306mm)%
textcolor{red}{uuuuuuu}
end{textblock*}
end{document}
I added a noindent
before zsavepos{P1}
inside the definition of myfunction
so as to save the position P1
after starting a new paragraph (which was done by myfunction
's first argument in your code, and caused the saved position to be above the baseline of the typeset text corresponding to #1
).
I also added [0,1]
after begin{textblock*}{thetextwidth}
in order to vertically shift the block continaing uuuuuuu
by its height (otherwise, its upper left corner would be at P1
's baseline, not its lower left one).
documentclass{article}
usepackage{xcolor}
usepackage[paperwidth=210 mm,paperheight=297 mm,left=50mm,top=20mm]{geometry}
usepackage[absolute,overlay]{textpos}
usepackage[savepos]{zref}
topskip=0pt
setlength{parindent}{0pt} % = global noindent
renewcommand{baselinestretch}{1.3}
newcommand{myfunction}[1]{%
noindentzsavepos{P1}% Store the current position as #1
#1%
}
textblockorigin{0mm}{297mm}
begin{document}
some text
myfunction{P1}
begin{textblock*}{textwidth}[0,1](zposx{P1}sp,-zposy{P1}sp)%
textcolor{red}{uuuuuuu}
end{textblock*}
% With multiline text
begin{textblock*}{textwidth}[0,1](zposx{P1}sp,-zposy{P1}sp)%
begin{minipage}[t]{textwidth}
color{blue}... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
end{minipage}
end{textblock*}
end{document}
Correct answer by frougon on February 19, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP