pdfsavepos 坐标保持为零

pdfsavepos 坐标保持为零

下面的我的 MWE 在文件中生成以下内容\jobname.ypos.txt

{1}{1}{1}{F}{0}
{1}{1}{1}{L}{0}
{1}{1}{2}{F}{0}
{1}{1}{2}{L}{0}
{1}{1}{3}{F}{0}
{1}{1}{3}{L}{0}

其中末尾的一堆零被认为是来自\pdfsavepos和的y 位置坐标pdflastypos

我显然在这里遗漏了一些基本的东西,但却无法弄清楚。

梅威瑟:

\documentclass[pagesize=pdftex, fontsize=10]{scrbook}
\usepackage[paperwidth=11.2cm, paperheight=17.4cm, top=1cm,bottom=1cm, left=1cm, right=1cm]{geometry}
\usepackage{pdfcolparallel,hanging}
\usepackage{fontspec}

\defaultfontfeatures{Mapping=tex-text}
\setmainfont{Times New Roman}

% Write the position to file.
% #1 is the book number
% #2 is the chapter number
% #3 is the verse number
% #4 is the position, first (F) or last (L), to be saved
\def\msec@write@lines#1#2#3#4{%
    \pdfsavepos%
    \immediate\write\yposoutputfile{%
    \string{#1\string}%
    \string{#2\string}%
        \string{#3\string}%
    \string{#4\string}%
        \string{\the\pdflastypos\string}%
    }%
}

\begin{document}
\newwrite\yposoutputfile%
\immediate\openout\yposoutputfile=\jobname.ypos.txt%

\LARGE{1} \msec@write@lines{1}{1}{1}{F} LIBRO de la generación de Jesucristo, hijo de David, hijo de Abraham. \msec@write@lines{1}{1}{1}{L}
\msec@write@lines{1}{1}{2}{F} \textbf{2}~Abraham engendró á Isaac: é Isaac engendró á Jacob: y Jacob engendró á Judas y á sus hermanos:\msec@write@lines{1}{1}{2}{L}
\msec@write@lines{1}{1}{3}{F} \textbf{3}~Y Judas engendró de Thamar á Phares y á Zara: y Phares engendró á Esrom: y Esrom engendró á Aram:\msec@write@lines{1}{1}{3}{L}

\immediate\closeout\yposoutputfile%
\end{document}

答案1

发货时位置已知,因此您不能使用\immediate\write。没有\immediate

\documentclass[pagesize=pdftex, fontsize=10]{scrbook}
\usepackage[paperwidth=11.2cm, paperheight=17.4cm, top=1cm,bottom=1cm, left=1cm, right=1cm]{geometry}
\usepackage{pdfcolparallel,hanging}
\usepackage{fontspec}

\defaultfontfeatures{Mapping=tex-text}
\setmainfont{Times New Roman}

% Write the position to file.
% #1 is the book number
% #2 is the chapter number
% #3 is the verse number
% #4 is the position, first (F) or last (L), to be saved
\def\msec@write@lines#1#2#3#4{%
    \pdfsavepos%
    \write\yposoutputfile{%
    \string{#1\string}%
    \string{#2\string}%
        \string{#3\string}%
    \string{#4\string}%
        \string{\the\pdflastypos\string}%
    }%
}

\begin{document}
\newwrite\yposoutputfile%
\openout\yposoutputfile=\jobname.ypos.txt%

\LARGE{1} \msec@write@lines{1}{1}{1}{F} LIBRO de la generación de Jesucristo, hijo de David, hijo de Abraham. \msec@write@lines{1}{1}{1}{L}
\msec@write@lines{1}{1}{2}{F} \textbf{2}~Abraham engendró á Isaac: é Isaac engendró á Jacob: y Jacob engendró á Judas y á sus hermanos:\msec@write@lines{1}{1}{2}{L}
\msec@write@lines{1}{1}{3}{F} \textbf{3}~Y Judas engendró de Thamar á Phares y á Zara: y Phares engendró á Esrom: y Esrom engendró á Aram:\msec@write@lines{1}{1}{3}{L}

\closeout\yposoutputfile%
\end{document}

该文件test.ypos.tex包含:

{1}{1}{1}{F}{29794429}
{1}{1}{1}{L}{26910845}
{1}{1}{2}{F}{26910845}
{1}{1}{2}{L}{24027261}
{1}{1}{3}{F}{24027261}
{1}{1}{3}{L}{19701885}

相关内容