这是另一个问题,但原来的问题已经(有点)解决了。
对于这个问题你需要XeTeX,Minion Pro,它与Adobe Reader一起提供。greybox.png
可以获得这里背景网格取自这个答案。
代码如下:
\newbox\gridbox
\setbox\gridbox\line{%
\special{color push rgb .8 .8 1}%
\vrule height\baselineskip width0pt \hrulefill
\special{color pop}}
\def\grid{\vtop to0pt{\hrule height0pt\kern-\dimexpr\baselineskip-\topskip\topskip=10pt\relax
\vbox to\dimexpr\vsize+2pt\relax{\leaders\copy\gridbox\vfil}\vss}}
\def\pagebody{\vbox to\vsize{\boxmaxdepth=\maxdepth \grid\pagecontents}}
\parskip=0pt \frenchspacing \raggedbottom
\parindent=1pc
\font\rm="Minion Pro:+onum,+pnum:mapping=tex-text" at 10pt
\font\it="Minion Pro/I:+onum,+pnum:mapping=tex-text" at 10pt
\rm
\footline={\hfil\rm\folio\hfil}
\newcount\shapenum \newcount\tempnum \newcount\globpar
\newdimen\ii \newdimen\ww
\newdimen\picwidth \newbox\picbox
\catcode`\@=11
\def\oblom #1 from #2 indent #3 {\par \ii=#1 \ww=\hsize
\ifdim\ii>\z@ \advance\ww by-\ii
\else \advance\ww by\ii \ii=\z@ \fi
\shapenum=1 \tempnum=0 \def\shapelist{}
\loop \ifnum\shapenum<#2 \edef\shapelist{\shapelist\z@\hsize}
\advance\shapenum by1 \repeat
\loop \edef\shapelist{\shapelist\ii\ww}
\advance\tempnum by1 \ifnum\tempnum<#3 \repeat
\advance\shapenum by#3 \edef\shapelist{\shapelist\z@\hsize}
\doshape}
\catcode`\@=12
\def\doshape{\globpar=0 \def\par{\ifhmode\shapepar\fi}}
\def\shapepar{\prevgraf=\globpar \parshape\shapenum\shapelist
\endgraf \globpar=\prevgraf
\ifnum \prevgraf>\shapenum \global\let\par=\endgraf \doshapeA \fi}
\ifx\XeTeXpicfile\undefined
\def\pic #1{\hbox{\pdfximage width\picwidth {#1}\pdfrefximage\pdflastximage}}
\else
\def\pic #1{\hbox{\XeTeXpicfile #1 width\picwidth}}
\fi
\def\\{\par}
\def\flowpic from #1 minus #2 width #3 #4#5{\par
\dimen0=#3 \ifdim\dimen0<0pt \dimen0=-\dimen0 \fi
%\advance\dimen0 by -1pc %(margin around picture)
% create this margin differently: add margin to #3
\dimen2=#3 \ifdim\dimen2<0pt \advance\dimen2 by -1pc
\else \advance\dimen2 by 1pc \fi
\picwidth=\dimen0
\setbox0=\vbox{\hsize\picwidth\pic{#4}%\kern .7mm
\emergencystretch=2em \noindent\it #5\par}
\dimen0=\ht0
\divide\dimen0 by\baselineskip \advance\dimen0 by1sp
\advance\dimen0 by -#2sp
\oblom \dimen2 from #1 indent \dimen0
\advance\dimen0 by #2sp
\multiply\dimen0 by\baselineskip
\setbox\picbox=\vbox to\dimen0{\vss\box0}
\dimen0=\pagegoal \ifdim\pagegoal=\maxdimen \dimen0=\vsize\fi
\advance\dimen0 by-\pagetotal \advance\dimen0 by-#1\baselineskip
\ifdim\dimen0<0pt
\def\doshapeA{\tempnum=\prevgraf \advance\tempnum by-#1 \advance\tempnum by2
\line{\ifdim#3<0pt \hfill\fi \vbox to0pt{\vss\vtop to0pt{\kern0pt\box\picbox\vss}%
\kern\the\tempnum\baselineskip}\hfil}
\nobreak\vskip-\baselineskip
}
\else \def\doshapeA{}
\line{\ifdim#3<0pt \hfill\fi
\vtop to0pt{\kern-2\baselineskip\kern#1\baselineskip\box\picbox\vss}\hfil}
\nobreak\vskip-\baselineskip
\fi
}
\noindent
A work in progress, {\tt JSBox} is a self-contained
library---written in portable C---that instantiates sandbox-able,
\TeX-language interpreters within the memory space
of any C, Objective-C, or C++ 32- or 64-bit client
program. Built and documented anew, {\tt JSBox}
is faithful to the \TeX\ language's primitives,
syntax, typesetting algorithms, measurements, data
structures, and speed. At the same time, it fixes---in an
upwardly compatible manner---a variety of important
problems with or lacunæ in the current \TeX\ engine's
implementation. These include integral support for
21-bit Unicode, namespaces, OpenType font tables
and metrics, job-specific 8-bit to 21-bit Unicode
mapping, run-time settable compatibility levels,
full 32-bit fixed-point math, and more.
Especially pertinent to interactive applications---such as an
eBook reader---is that all of a document's pages can
optionally be kept as \TeX\ data structures in memory
after a job is done, with direct random access of any
requested page exported to the client program's screen
without file I/O or DVI or PDF conversion if unneeded.
Tracing (including recursive expansion, re-tracing
interrupted commands, alignments, math, etc.) and
all error messages have been significantly improved
over what \TeX\ does. The author will demo what
{\tt JSBox} can do now, and discuss what it
could do in the future.
A work in progress, {\tt JSBox} is a self-contained
library---written in portable C---that instantiates sandbox-able,
\TeX-language interpreters within the memory space
of any C, Objec\-tive-C, or C++ 32- or 64-bit client
program. Built and documented anew, {\tt JSBox}
is faithful to the \TeX\ language's primitives,
syntax, typesetting algorithms, measurements, data
structures, and speed. At the same time, it fixes
in an
upwardly compatible manner---a variety of important
problems with or lacunæ in the current \TeX\ engine's
implementation. These include integral support for
21-bit Unicode, namespaces, OpenType font tables
and metrics, job-specific 8-bit to 21-bit Unicode
mapping, run-time settable compatibility levels,
full 32-bit fixed-point math, and more. Especially
pertinent to interactive applications---such as an
eBook reader---is that all of a document's pages can
optionally be kept as \TeX\ data structures in memory
after a job is done, with direct random access of any
requested page exported to the client program's screen
without file I/O or DVI or PDF conversion if unneeded.
Tracing (including recursive expansion, re-tracing
interrupted commands, alignments, math, etc.) and
all error messages have been significantly improved
over what \TeX\ does. The author will demo what
{\tt JSBox} can do now, and discuss what it
could do in the future.
\flowpic from 11 minus 0 width -7cm {greybox.png}{The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.}
A work in progress, {\tt JSBox} is a self-contained
library---written in portable C---that instantiates sandbox-able,
\TeX-language interpreters within the memory space
of any C, Objective-C, or C++ 32- or 64-bit client
program. Built and documented anew, {\tt JSBox}
is faithful to the \TeX\ language's primitives,
syntax, typesetting algorithms, measurements, data
structures, and speed. At the same time, it fixes---in an
upwardly compatible manner---a variety of important
problems with or lacunæ in the current \TeX\ engine's
implementation. These include integral support for
21-bit Unicode, namespaces, OpenType font tables
and metrics, job-spe\-cific 8-bit to 21-bit Unicode
mapping, run-time settable compatibility levels,
full 32-bit\nobreak\ fixed-point math, and more.
Especially pertinent to interactive applications---such as an
eBook reader---is that all of a document's pages
can optionally be kept as \TeX\ data structures in memory
after a job is done, with direct random access of any
requested page exported to the client program's screen
without file I/O or DVI or PDF conversion if unneeded.
Tracing (including recursive expansion, re-tracing
interrupted commands, alignments, math, etc.) and
all error messages have been significantly improved
over what \TeX\ does. The author will demo what
{\tt JSBox} can do now, and discuss what it
could do in the future.
A work in progress, {\tt JSBox} is a self-contained
library---written in portable C---that instantiates sandbox-able,
\TeX-language interpreters within the memory space
of any C, Objective-C, or C++ 32- or 64-bit client
program. Built and documented anew, {\tt JSBox}
is faithful to the \TeX\ language's primitives,
syntax, typesetting algorithms, measurements, data
structures, and speed. At the same time, it fixes---in an
upwardly compatible manner---a variety of important
problems with or lacunæ in the current \TeX\ engine's
implementation. These include integral support for
21-bit Unicode, namespaces, OpenType font tables
and metrics, job-specific 8-bit to 21-bit Unicode
mapping, run-time settable compatibility levels,
full 32-bit fixed-point math, and more.
These include integral support for
21-bit Unicode, namespaces, OpenType font tables
and metrics, job-specific 8-bit to 21-bit Unicode
mapping, run-time settable compatibility levels,
full 32-bit fixed-point\nobreak\ math, and more. These include integral support for
21-bit Unicode,{\parfillskip=0pt\par}
\flowpic from 1 minus 0 width -7cm {greybox.png}{The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.}
\noindent namespaces, OpenType font tables
and metrics, job-specific 8-bit to 21-bit Unicode
mapping, run-time settable compatibilitylevels,
full 32-bit fixed-point math, and more. Especially
pertinent to interactive applications---such as an
eBook reader---is that all of a document's pages can
optionally be kept as \TeX\ data structures in memory
after a job is done, with direct random access of any
requested page exported to the client program's screen
without file I/O or DVI or PDF conversion if unneeded.
Tracing (including recursive expansion, re-tracing
interrupted commands, alignments, math, etc.) and
all error messages have been significantly improved
over what \TeX\ does. The author will demo what
{\tt JSBox} can do now, and discuss what it
could do in the future.
A work in progress, {\tt JSBox} is a self-contained
library---written in portable C---that instantiates sandbox-able,
\TeX-language interpreters within the memory space
of any C, Objective-C, or C++ 32- or 64-bit client
program. Built and documented anew, {\tt JSBox}
is faithful to the \TeX\ language's primitives,
syntax, typesetting algorithms, measurements, data
structures, and speed. At the same time, it fixes---in an
upwardly compatible manner---a variety of important %\nobreak\
problems with or lacunæ in the current \TeX\ engine's
implementation. These include integral support for
21-bit Unicode, namespaces, OpenType font tables
and metrics, job-specific 8-bit to 21-bit Unicode
mapping, run-time settable compatibility levels,
full 32-bit fixed-point math, and more. Especially
pertinent to interactive applications---such as an
eBook reader---is that all of a document's pages can
optionally be kept as \TeX\ data structures in memory
after a job is done, with direct random access of any
requested page exported to the client program's screen
without file I/O or DVI or PDF conversion if unneeded.
Tracing (including recursive expansion, re-tracing
interrupted commands, alignments, math, etc.) and
all error messages have been significantly improved
over what \TeX\ does. The author will demo what
{\tt JSBox} can do now, and discuss what it
could do in the future.
\bye
可以看到,第 2 页的图片被移动到了左边:
(还请注意图片下方较宽的标题)。奇怪的是,当我删除 的(重新)声明\rm
,因此使用 cmr10 时,图像不会向左移动(标题中使用 Minion Italic 显然无关紧要)。
这是为什么?这是 XeTeX 的一个 bug 吗?
答案1
问题的核心是\par
你的代码第54行的标记:
\setbox0=\vbox{\hsize\picwidth\pic{#4}%\kern .7mm
\emergencystretch=2em \noindent\it #5\par}
如果缩进未完成,宏会临时重新定义 token 以重置下一段的参数。这就是为何 适用于多个段落的原因。\oblom
请\par
注意,普通 TeX会明确删除设置,因此如果不重新定义 ,则无法跨多个段落使用它。\parshape
\oblom
\par
\parshape
\par
因此,\par
代码中第 54 行的 被扩展为宏,这就是排版错误的原因。解决方案:只需删除\par
此处,因为如果在此处检测到水平模式,则在 末尾会自动调用段落创建\vbox
。这是一个例外来自另一个自动\par
处理:在 TeX 中,\par
这里不插入任何标记(另一方面,在、等原语\par
之前插入了这些原语的标记,第 90-91 页\vskip
\end
TeXbook 纳鲁比)。
您可以反对,\par
因为前面段落的所有缩进行都已打印,因此不需要在这里重新定义,并且\par
可以通过
\ifnum \prevgraf>\shapenum \global\let\par=\endgraf \doshapeA \fi}
这是真的,但是这段代码有一个小错误,因为我们需要说\ifnum\prevgraf>=\shapenum...
哪些可以通过以下方式编码:
\ifnum \prevgraf<\shapenum\else \global\let\par=\endgraf \doshapeA \fi}
我在我的宏代码中发现了这个错误,\oblom
感谢您的问题。谢谢,我会在勘误表中更正此问题TeXbook 纳鲁比。