
次のコードは、画像とそれに付随するテキストを本文テキストで囲みます。このように設定すると (s を使用\vfill
)、画像とテキストはくぼみの垂直方向の中央に配置されます。
私が実現したいのは、画像の下のテキストをベースライン グリッドに揃えることです (両方を下げることによって)。3\vfill
番目のパラメータ内の最後の値を省略すると、\figflow
テキストが低く設定されすぎます。
リソース: XeTeXを使用しています(画像を含めるため)図フロー、グレーボックス.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}}
\input figflow
\parskip=0pt \frenchspacing \raggedbottom
\font\smallrm=cmr8
\def\includegraphics#1#2#3#4{
{\parfillskip=0pt\par}\dimen0=#1
\dimen1=#2
\advance\dimen0 by 1pc
\setbox0=\vbox to #2{\hsize=#1
\XeTeXpicfile #3 width #1 height #2}
\setbox1=\vbox{\hsize=#1{\noindent\it #4\par}}
\advance\dimen1 by \ht1
\divide\dimen1 by \baselineskip
\multiply\dimen1 by \baselineskip
\advance\dimen1 by \baselineskip
\setbox2=\vbox to \dimen1{\vfil\box0\vskip2mm\box1}
\figflow{\dimen0}{\dimen1}{\vfill\box2\vfill}\noindent\ignorespaces}
\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\ae\ 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.%
\includegraphics{7cm}{7cm}{greybox.png}{Lorem ipsum dolor sit
amet, consectetur adipiscing elit. Donec a diam lectus.}
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\ae\ 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
アップデート:
でこれ\baselineskip
図の下のテキストのフォントサイズが本文と同じ場合、行\figflow
を次のように変更することでベースラインを揃えることができました。
\figflow{\dimen0}{\dimen1}{\vfill\box2\vskip0pt}\noindent\ignorespaces}
空の挿入が機能するのはなぜですか\vskip
? 他のフォント サイズや他の では機能せず、ボックス 1 内のグループの内外に を\baselineskip
挿入する場合でも機能しないことに注意してください。\strut
更新2:
wipet さんの回答のおかげで、それほど珍しくないケースである、画像とキャプションをページの右下 (または左下) 隅に配置する必要がある別の MWE を作成しました。
\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}}
\input figflow
\parskip=0pt \frenchspacing \raggedbottom
\font\smallrm=cmr8
\def\includegraphics#1#2#3#4{%
{\parfillskip=0pt\par}
\dimen0=#1 \ifdim#1<0pt \dimen0=-\dimen0 \fi
\dimen1=#2
\dimen2=#1 \advance\dimen2 by \ifdim#1<0pt-\fi 1pc
\setbox0=\vbox {\XeTeXpicfile #3 width\dimen0 height #2}
\setbox1=\vbox{\hsize=\dimen0 \baselineskip=9.5pt\noindent\smallrm #4\par}
\advance\dimen1 by \ht1
\divide\dimen1 by \baselineskip
\multiply\dimen1 by \baselineskip
\advance\dimen1 by 1\baselineskip
\setbox2=\vbox to\dimen1{\vss\box0\vskip2mm\box1}
\figflow{\dimen2}{\dimen1}{}%
\line{\ifdim#1<0pt\hfill\fi\vtop to0pt{\kern0pt\box2\vss}\hfil}
\nobreak\vskip-\baselineskip
\noindent\ignorespaces}
\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\ae\ 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, 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\ae\ 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, 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\ae\ 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%
\includegraphics{-7cm}{7cm}{greybox.png}{Lorem ipsum dolor sit
amet, consectetur adipiscing elit. Donec a diam lectus.}
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\ae\ 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
問題は (私が思うに) どこかに が\baselineskip
挿入され、\vskip-\baselineskip
マクロの最後で を使用して元に戻されていることです。これにより、\baselineskip
画像全体と画像の隣にあるテキストが次のページに表示されます。呼び出しを\includegraphics
1 行上 ( の前Especially …
) に移動すると、画像は最初のページに表示されますが、画像とキャプション テキストの下に 1 行の本文テキストが表示されます。
更新3:
ページの排出は、figflow.tex に画像を挿入したときに行われました。\nobreak
ある時点で を追加したところ ( でマーク^^^
)、排出はなくなりました。
% FIGFLOW: plain TEX macro by Ian Hutchinson, 21 Oct 95.
% Copyright 1995 Ian Hutchinson.
% You may freely use, modify, and/or distribute this file, without limitation.
% Make text flow round figure.
% Usage: \figflow{<width>}{<height>}{<[Figure+][Caption]>}
% at start of new paragraph. Figure top starts at insert.
% #1 figure width dimen. If negative, fig on right, else left.
% #2 figure height (including caption) dimen. (E.g.: 4 truein)
% #3 \special for figure if desired, then \vfill caption. (Both optional).
% Example: figflow{4 truein}{5 truein}{\epsfbox{figure.ps}\vfill Figure 1.}
% User is responsible for the figure fitting within the space defined.
% If figure won't fit on page, it is moved over the page break.
% If a new figflow starts before the old one is finished, a message is given
% and the second figure is skipped. Fix manually.
% Does not work for Latex.
\newdimen\pageremains\newdimen\pdepth
\newdimen\figwidth
\newdimen\figheight
\newcount\figlines
\newcount\flevel
\def\figflow#1#2#3{
\ifnum\flevel>0
\message{******Figure collision. Ignoring second figure.******}
\else
\figwidth=#1
\figheight=#2
\def\contents{#3}
% Put figure contents in an appropriate box.
\def\figure{\let\temp=\par \let\par=\plainpar
\line{\overfullrule=0pt% Avoid black box.
\ifdim \figwidth<0pt \hsize=-\figwidth \hss\else \hsize=\figwidth\fi
\advance \hsize by -10pt% Give a little extra hspace.
\vbox to \figheight{\vfil\noindent\contents}
\ifdim \figwidth>0pt \hss\fi
}\nobreak\vskip-\figheight
% ^^^^^^^^ inserted by MK
\let\par=\temp%
}
% […] remainder of file is the same
\widowpenalty
現在存在する唯一の問題は、ページの最後の 2 行が次の行に移動されることです (短縮も含む)。これはとに関係していると思いますが\clubpenalty
、これらの変数をいじっても問題は解決しませんでした。
前述の問題に対するより良い解決策もいただければ幸いです。
アップデート4:
\nobreak\̺
最初のページの本文の最後の単語の後に を手動で追加すると(つまり、 の後a variety of important
)、アップデート 3 で言及された問題は確かに解決されますが、この時点では改行も禁止されるため、行が (あまりにも) 狭くなり、不要なハイフン付けが発生します。これを解決し、もちろん自動化するにはどうすればよいでしょうか?
アップデート5:
何らかのストレス テストを実行しているときに、別の問題が発生しました。開始する前に、それぞれまたはを追加するために、2つのマクロ\toppicture
とを追加しました(このコードの長さを理由に敬遠しないでください。大部分はダミー テキストです)。\midpicture
\eject
\par
\includegraphics
\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}}
\input figflow
\parskip=0pt \frenchspacing \raggedbottom
\widowpenalty=10000 \clubpenalty=10000
\font\smallrm=cmr8
%\toppicture params:
% #1 <dimen> width of picture
% #2 <dimen> height of picture
% #3 <string> file name
% #4 <string> caption text
\def\toppicture#1#2#3#4{%
{\parfillskip=0pt\par}\eject%
\includegraphics{#1}{#2}{#3}{#4}
}
%\midpicture params:
% #1 <dimen> width of picture
% #2 <dimen> height of picture
% #3 <string> file name
% #4 <string> caption text
\def\midpicture#1#2#3#4{%
{\parfillskip=0pt\par}
\includegraphics{#1}{#2}{#3}{#4}
}
\def\includegraphics#1#2#3#4{%
\dimen0=#1 \ifdim#1<0pt \dimen0=-\dimen0 \fi
\dimen2=#2
\dimen4=#1 \advance\dimen4 by \ifdim#1<0pt-\fi 1pc
\setbox0=\vbox {\XeTeXpicfile #3 width\dimen0 height #2}
\setbox2=\vbox{\hsize=\dimen0 \baselineskip=9.5pt\noindent\smallrm #4\par}
\advance\dimen2 by \ht2
\divide\dimen2 by \baselineskip
\multiply\dimen2 by \baselineskip
\advance\dimen2 by \baselineskip
\setbox4=\vbox to\dimen2{\vss\box0\vskip2mm\box2}
\figflow{\dimen4}{\dimen2}{}
\line{\ifdim#1<0pt\hfill\fi\vtop to0pt{\kern0pt\box4\vss}\hfil}
\nobreak\vskip-\baselineskip
\noindent\ignorespaces}
\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\ae\ 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, 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\ae\ 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, 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\ae\ 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
\midpicture{-7cm}{7cm}{greybox.png}{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus.}
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\ae\ in the current \TeX\ engine's
implementation. These include integral support for
21-bit Unicode,
%\midpicture{7cm}{7cm}{greybox.png}{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus.}
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 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 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
\midpicture{7cm}{7cm}{greybox.png}{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus.}
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.
%\toppicture{7cm}{7cm}{greybox.png}{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus.}
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\ae\ 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 番目をコメント アウト\midpicture
し (169 行目にあるはずです)、XeTeX を実行します。いずれにしても、更新 3 ( \nobreak
figflow.tex への追加) と更新 4 (\nobreak\
ソース コピーへの追加) で行った変更を省略でき、すべてが適切にタイプセットされます。私が知る限り、他には何も変更していないので、これは非常に奇妙です。テキストは、画像と画像のキャプションの周囲に正しく流れます。
では、\midpicture
先ほどコメントアウトした呼び出しのコメントを解除して、TeX を再度実行してください。今度は、}
の直前にを挿入することについてエラーが出ます\endgroup
。これは奇妙に思えます。ここで何が起こっているのでしょうか?
3 番目に、その行を再度コメント アウトし、\midpicture
149 行目のコメントを解除します。これで、figflow.tex は図の衝突についてエラーを出します。\midpicture
これは、行の最後の単語の後にマクロを呼び出しましたが、最初の図の横の行の処理が完了していないためと思われます。これは、2 つの図を互いに直下に配置できない (衝突してはならない) ことを意味します。この衝突を回避するにはどうすればよいでしょうか。
4 番目に、149 行目を再度コメントアウトし、\toppicture
178 行目の , のみをコメントアウト解除します。不思議なことに、今回は\figflow
169 行目をコメントアウトしたときのように、TeX が 2 回目の呼び出しで詰まることはありません。結果は、正しくタイプセットされた 2 ページと、左上に画像がある新しいページです。ただし、今度はすべて (本文、画像、画像キャプション) が少しグリッドから外れています。何が間違っているのでしょうか。
答え1
\figflow
写真のための適切なスペースを作成するためだけに使用し、写真の配置を私たちの管理下で行うことをお勧めします。
\def\includegraphics#1#2#3#4{
{\parfillskip=0pt\par}\dimen0=#1
\dimen1=#2
\advance\dimen0 by 1pc
\setbox0=\vbox to #2{\hsize=#1
\XeTeXpicfile #3 width #1 height #2}
\setbox1=\vbox{\hsize=#1{\noindent\it #4\par}}
\advance\dimen1 by \ht1
\divide\dimen1 by \baselineskip
\multiply\dimen1 by \baselineskip
\advance\dimen1 by 1\baselineskip
\setbox2=\vbox to \dimen1{\vfil\box0\vskip2mm\box1}
% PO changes in OP's code:
\figflow{\dimen0}{\dimen1}{}%
\vtop to0pt{\kern0pt\box2\vss}\nobreak\vskip-\baselineskip
\noindent\ignorespaces}
inside\kern-\baselineskip
ではなくを設定すると、画像は 1 行上に配置されます。\kern0pt
\vtop
編集: コメントを考慮して、コードの 2 番目のバージョンを追加しました。ここでは、\baselineskip
画像の下のテキストの は任意で、\includegraphics
マクロの最初のパラメータは負の値にすることができます。すると、 は\dimen0
このパラメータの絶対値となり、 はプラスまたはマイナス 1pc\dimen2
として新たに導入されます#1
( の符号に応じてマージンを追加します#1
)。
\def\includegraphics#1#2#3#4{%
{\parfillskip=0pt\par}
\dimen0=#1 \ifdim#1<0pt \dimen0=-\dimen0 \fi
\dimen1=#2
\dimen2=#1 \advance\dimen2 by \ifdim#1<0pt-\fi 1pc
\setbox0=\vbox {\XeTeXpicfile #3 width\dimen0 height #2}
\setbox1=\vbox{\hsize=\dimen0 \noindent\it #4\par}
\advance\dimen1 by \ht1
\divide\dimen1 by \baselineskip
\multiply\dimen1 by \baselineskip
\advance\dimen1 by 1\baselineskip
\setbox2=\vbox to\dimen1{\vss\box0\vskip2mm\box1}
\figflow{\dimen2}{\dimen1}{}%
\line{\ifdim#1<0pt\hfill\fi\vtop to0pt{\kern0pt\box2\vss}\hfil}
\nobreak\vskip-\baselineskip
\noindent\ignorespaces}
編集2:\oblom
あなたの質問の更新を考慮して、私の本のマクロを試してみることにしましたTeXbook ナルビー(236 ページと 237 ページ) この本の完全な PDF 版はチェコ語でのみ利用可能です。
このマクロの名前は、\oblom
チェコ語の「何かの周りにタイプセットを行う」に由来しています。このマクロは、次の段落 (または複数の段落) に白い長方形のスペースを作成します。次のコードでは、このマクロを使用しています (ただし、区切り文字の名前は変更しています)。このマクロの使用方法は次のとおりです。
\oblom <width> from <linenum1> indent <linenum2>
ここで、<width>
は長方形のスペースの幅、<linenum1>
はインデントされる最初の行番号、 は<linenum2>
インデントされる行の数です。 が<width>
負の場合、長方形のスペースは右側になります。例:
\oblom 5cm from 3 indent 5
は、5 行が 3 行目から 5cm インデントされることを意味します (この行を含む)。最初の 2 行はインデントされず、通常の幅のままです。
マクロは\oblom
段落間で使用し、次の 1 つ以上の段落の形状に影響します。主な利点は、段落をインデントの開始位置で正確に停止する必要がないことです。{\parfillskip=0pt\par}
複雑化を招く前に実行する必要がある例に注意してください。
次のコードでは\oblom
、マクロを使用して定義します\flowpic
。
\flowpic from <linenum> width <width> {<picfile>} {<caption>}
例えば
\flowpic from 3 width -7cm {greybox.png}
{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus.}
次の段落の 3 行目から、指定されたキャプションが付いた画像をgreybox.png
右側に挿入します。画像の幅は 7cm から 1pc を引いたものになります。1pc は画像とテキストの間の余白です。パッケージを使用する必要はありませんfigflow
。
コードは3つの部分から構成されています。最初の部分は\oblom
、TeXbook ナルビーこのマクロは\parshape
パラメータを計算し、 を使用します\parshape
。2 番目の部分は、指定された幅の画像を挿入するためのマクロを定義します\pic
。定義は、XeTeX が使用されているかどうかによって異なります。3 番目の部分は、と を\flowpic
使用するものを宣言します。flowpic マクロは、十分なスペースがある場合、画像が使用されている同じページに画像を挿入します。十分なスペースがない場合、flowpic は、形状が変更された最後の段落が終了する次のページに画像を挿入します。\oblom
\pic
\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\else \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\flowpic from #1 width #2 #3#4{\par
\dimen0=#2 \ifdim\dimen0<0pt \dimen0=-\dimen0 \fi
\advance\dimen0 by -1pc %(margin around picture)
\picwidth=\dimen0
\setbox0=\vbox{\hsize\dimen0 \pic{#3}\kern 2mm
\emergencystretch=2em \noindent\it #4}
\dimen0=\ht0
\divide\dimen0 by\baselineskip \advance\dimen0 by1sp
\oblom #2 from #1 indent \dimen0
\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#2<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#2<0pt \hfill\fi
\vtop to0pt{\kern-2\baselineskip\kern#1\baselineskip\box\picbox\vss}\hfil}
\nobreak\vskip-\baselineskip
\fi
}
\parindent=0pt \raggedbottom % we need the grid
このマクロの制限は、ページ区切りがあるページの「端」に画像を配置できないことです。そのようなページ区切りの前または後にのみ配置できます。1 つの段落に 2 つの画像を挿入することはできません。次の の使用は、\flowpic
前の によってインデントされた行がない段落の前でのみ許可されます\flowpic
。段落が非常に長く、ここに 2 つの を配置する必要がある場合は、前の「見えない」段落を閉じるために\flowpic
による既知のトリックを使用する必要があります。{\parfillskip=0pt\par}