2

Does anyone know how or which commands should i issue from within a .tex file so that the tex compiler would generate a descriptor file pointing metadata of the generated PDF (such as pixel locations of regions of interests on the documents and other usefull info contained within the document). Up until now the best tip i got was to create my own stylefile with the definition of new commands ( position handler commands) "which are used to return the cartesian pixel locations of where the handler commands are used". Thanks in advance

  • 1
    Welcome to TeX.SE! Could you provide an example of a .tex file with the corresponding metadata file? – Marijn Nov 16 '18 at 16:05
  • 1
    perhaps you are looking for \pdfsavepos but it is hard to be sure, or what you mean by "pixel" in a scalable format like PDF. – David Carlisle Nov 16 '18 at 16:36
  • It looks like you've got two separate accounts, which means you cannot edit your original post or leave comments. The Stack Exchange staff can merge them together for you. – user36296 Nov 17 '18 at 17:39
  • BTW, @samcarter explained your follow-up question to me (which you put in an answer field). The answer is: you do not need the overlay picture. – user121799 Nov 17 '18 at 18:36
  • 1
    Extending @marmot comment: The code block \tikz[overlay,remember picture]{...}shows you how to use the coordinates retrieved from the log file by drawing the arrows you see in the picture. – user36296 Nov 17 '18 at 18:47
2

Welcome to TeX.SE! As far as I know, TikZ stores absolute coordinates in the aux file. This is basically how rememer picture works. To make this more explicit, let us look at the MWE

\documentclass{article}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\lipsum[1]

\tikzmark{a}Hello world!\tikzmark{b}

\end{document}

which produces an aux file

\relax 
\savepointas{a}{pgfid1}{0pt}{0pt}
\savepicturepage{pgfid1}{1}
\pgfsyspdfmark {pgfid1}{9782558}{33796915}
\savepointas{b}{pgfid2}{0pt}{0pt}
\savepicturepage{pgfid2}{1}
\pgfsyspdfmark {pgfid2}{13243229}{33796915}

Here, the entries of \pgfsyspdfmark have the interpretation

\pgfsyspdfmark{pgfid<n>}{<x>}{<y>}

where n is the id, i.e. an integer, and x and y are the absolute page coordinates multiplied by 65536 (=2^16). This can be verified by the extended MWE

\documentclass{article}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{tikzmark,calc}
\begin{document}
\lipsum[1]

\tikzmark{a}Hello world!\tikzmark{b}

\tikz[overlay,remember picture]{
\draw[latex-] let \p1=($(pic cs:a)-(current page.south west)$),
\n1={978.2558/\x1},\n2={3379.6915/\y1} in
(pic cs:a) -- ++(0,-1) node[below] {$(\x1,\y1)\to(\n1,\n2) $};
\draw[latex-] let \p1=($(pic cs:b)-(current page.south west)$),
\n1={1324.3229/\x1},\n2={3379.6915/\y1} in
(pic cs:b) -- ++(6,-1) node[below] {$(\x1,\y1)\to(\n1,\n2) $};
}
\end{document}

enter image description here

where I had to divide by a factor 10^4 (since I did not want to load another package/library to enable handling of such large numbers).

So the upshot is that tikzmark allows you to write the absolute positions of "interesting points" to the aux file. These you could read out with some external program and use them for whatever you have in mind.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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