그림 텍스트와 본문 텍스트의 기준선을 정렬하는 방법은 무엇입니까?

그림 텍스트와 본문 텍스트의 기준선을 정렬하는 방법은 무엇입니까?

다음 코드는 그림과 그에 수반되는 텍스트 주위에 본문 텍스트를 래핑합니다. 이 방법으로 설정하면( \vfills를 사용하여) 그림과 텍스트가 홈의 수직 중앙에 위치합니다.

내가 달성하고 싶은 것은 그림 아래의 텍스트를 기준선 격자에 정렬하는 것입니다(둘 다 낮춤). \vfill세 번째 매개변수의 마지막 매개변수를 생략하면 \figflow텍스트가 너무 낮게 설정됩니다.

리소스: 저는 XeTeX를 사용하고 있습니다(그림 포함).figflow.tex,그레이박스.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 내의 그룹 내부 또는 외부에 s를 \baselineskip삽입하는 경우에도 다른 글꼴 크기나 다른 s에서는 작동하지 않습니다 .\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

문제는 매크로 끝에서 \baselineskipa를 사용하여 실행 취소되는 a가 삽입된 어딘가에 있다는 것입니다. \vskip-\baselineskip그러면 \baselineskip전체 그림과 그림 옆의 텍스트가 다음 페이지에 나타납니다. 호출을 \includegraphics한 줄 위로(앞 Especially …) 이동하면 그림이 첫 페이지에 나타나지만 그림과 캡션 텍스트 아래에 한 줄의 본문 텍스트가 표시됩니다.

업데이트 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

현재 존재하는 유일한 문제는 페이지의 마지막 두 줄이 다음 줄로 이동된다는 것입니다(단축 포함). 내 생각에는 \widowpenaltyand 와 관련이 있는 것 같지만 \clubpenalty해당 변수를 수정해도 문제가 해결되지 않았습니다.

앞서 언급한 문제에 대한 더 나은 해결책도 높이 평가됩니다.

업데이트 4:

\nobreak\̺첫 번째 페이지 본문 텍스트의 마지막 단어 뒤에(예: 이후 ) 수동으로 추가하면 a variety of important업데이트 3에서 언급된 문제가 해결되지만 이제 이 시점에서 줄바꿈도 금지되어 (너무) 줄이 빡빡해지고 불필요한 하이픈 넣기. 이 문제를 해결하는 방법과 자동화하는 방법은 무엇입니까?

업데이트 5:

일종의 스트레스 테스트를 수행할 때 또 다른 문제가 발생했습니다. 두 개의 매크로를 추가 \toppicture하고 시작하기 전에 \midpicture각각 \eject또는 a를 추가했습니다 (이 코드의 길이 때문에 부끄러워하지 마십시오. 대부분은 더미 텍스트입니다).\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

먼저 두 번째 항목을 주석 처리하고 \midpicture(169행에 있어야 함) XeTeX를 실행합니다. 어떤 식으로든 이제 업데이트 3( \nobreakfigflow.tex에 추가)과 업데이트 4( \nobreak\소스 복사본에 추가)에서 변경한 내용을 생략할 수 있으며 모든 것이 제대로 조판되었습니다. 내가 아는 한 다른 것은 아무것도 바꾸지 않았기 때문에 이것은 매우 이상합니다. 텍스트가 그림과 그림 캡션 주위에 올바르게 흐릅니다.

이제 \midpicture방금 주석 처리한 호출의 주석 처리를 해제하고 TeX를 다시 실행하십시오. 이제 }. 바로 앞에 을 삽입하는 것에 대해 불평합니다 \endgroup. 나에게는 이상하게 들린다. 여기서 무슨 일이 일어나는가?

셋째, 해당 라인을 다시 주석 처리하고 온라인 149 라인의 주석 처리를 제거합니다. 이제 figflow.tex는 그림 충돌에 대해 불평합니다. 아마도 행의 마지막 단어 다음에 매크로를 \midpicture호출했지만 첫 번째 그림 옆의 라인 처리가 완료되지 않았기 때문일 것입니다. \midpicture. 이는 두 개의 그림을 서로 바로 아래에 배치할 수 없음을 의미합니다(충돌해서는 안 됨). 이 충돌을 피하는 방법은 무엇입니까?

넷째, 149행을 다시 주석 처리하고 178행의 유일한 주석 처리를 제거합니다 \toppicture. 이상하게도 이번에는 TeX가 \figflow169행의 주석 처리를 제거했을 때 좋아요를 눌러 달라는 두 번째 호출에도 질식하지 않습니다. 그 결과 올바르게 조판된 페이지 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}

내부 \kern-\baselineskip가 아닌 설정을 하면 그림이 한줄 위로 배치됩니다.\kern0pt\vtop

편집: 주석을 고려하여 코드의 두 번째 버전을 추가했습니다. 여기서 \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개의 줄이 세 번째 줄(이 줄 포함)에서 5cm 들여쓰기된다는 의미입니다. 처음 두 줄은 들여쓰기되지 않았으며 일반 너비를 따릅니다.

매크로는 \oblom단락 사이에 사용해야 하며 다음 하나 이상의 단락의 모양에 영향을 줍니다. 가장 큰 장점은 들여쓰기가 시작되는 곳에서 정확히 단락을 멈출 필요가 없다는 것입니다. {\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.}

greybox.png오른쪽 다음 문단 세 번째 줄부터 주어진 캡션과 함께 그림을 삽입합니다 . 1pc는 그림과 텍스트 사이의 여백이므로 그림의 너비는 7cm에서 1pc를 뺀 값이 됩니다. pckage 를 사용할 필요가 없습니다 figflow.

코드는 세 부분으로 구성됩니다. 첫 번째 부분은 \oblom복사된 매크로 의 정의입니다 .TeXbook 나루비. 이 매크로는 매개 \parshape변수를 계산하고 \parshape. 두 번째 부분은 \pic주어진 너비의 그림을 삽입하기 위한 매크로를 정의합니다 . 정의는 XeTeX가 사용되는지 여부에 따라 달라집니다. 세 번째 부분에서는 및 를 \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

이 매크로의 제한 사항은 페이지 나누기가 있는 페이지의 "가장자리"에 그림을 배치할 수 없다는 것입니다. 그러한 페이지 나누기 전후에만 가능합니다. 한 문단에 두 개의 그림을 삽입할 수 없습니다. 의 다음 사용은 \flowpic이전 으로 들여쓰기된 줄이 없는 단락 앞에서만 허용됩니다 \flowpic. 매우 긴 단락이 있고 여기에 두 개의 를 배치해야 하는 경우 이전의 "보이지 않는" 단락을 닫으려면 \flowpic알려진 트릭을 사용해야 합니다 .{\parfillskip=0pt\par}

관련 정보