ConTeXT에서 다중 \starthanging \stophanging 관련 문제

ConTeXT에서 다중 \starthanging \stophanging 관련 문제

ConTeXT를 사용하여 추가 측면 텍스트가 있는 여러 그림을 차례로 배치하려고 합니다.

두 개의 도형이 연속으로 있으면 겹쳐집니다. 어떻게 분리해야 합니까?

다음 코드는 ConTeXT를 실행할 때 겹치는 그림을 만듭니다.

\starthanging{
\placefigure[force][fig:first]{Caption 1} {\externalfigure[first-figure][width=\textwidth]}}
\inother[width=5cm]{Some text for the other bit}
\stophanging

\starthanging{
\placefigure[force][fig:second]{Caption 2} {\externalfigure[second-figure][width=\textwidth]}}
 \inother[width=5cm]{Some text for the other bit 2}
\stophanging

내가하려는 것은 이것이다 :

여기에 이미지 설명을 입력하세요

답변1

Aditya가 언급했듯이 매달기를 사용하는 것은 여기서 잘못된 접근 방식입니다. 그가 Hans와 Wolfgang에 연결한 스레드에서 이미 두 가지 솔루션을 제공했습니다. Wolfgang의 솔루션을 기반으로 다음 기능을 갖춘 세 번째 솔루션을 제시하겠습니다.

  • 추가 텍스트는 그림에 가까운 것이 아니라 여백에 조판됩니다.
  • margindata 인터페이스를 사용합니다. 이를 통해 여백 텍스트를 일반적인 방법을 사용하여 조작할 수 있습니다.ConTeXt 인터페이스.
  • 가능한 한 낮은 수준의 명령을 피하려고 노력했습니다.
  • 추가 그림 텍스트는 선택 사항입니다.
  • 추가 여백 텍스트는 기본적으로 중앙에 배치됩니다. 높이가 그림 높이를 초과하면 위쪽에 정렬됩니다.

코드

\useMPlibrary [dum]  %% only for the screenshot

\setuppagenumbering
  [alternative=doublesided]

\definemargindata
  [FigureMargin]
  [inouter]
  [voffset=-\dimexpr\nextboxht-\strutheight\relax]

\definemarginframed
  [FigureMargin]
  [height=\nextboxht,
   align={flushleft, lohi}]

\starttexdefinition FigureText
  \dowithnextbox{
    \startlinealignment[middle]
      \copy\nextbox
      \doifsomething{\floatuserdataparameter{text}}
        {\FigureMargin{\floatuserdataparameter{text}}}
    \stoplinealignment
    }
    \hbox
\stoptexdefinition

\setupfloat
  [figure]
  [command=\FigureText]

먼저, 개별 마진 데이터 세트가 정의됩니다. 여백 텍스트를 올바르게 정렬하기 위해 다음과 같은 프레임을 사용합니다.프레임이 일반적으로 허용하는 모든 설정.

FigureText그런 다음 그림 내용과 추가 여백 텍스트를 조판하는 명령이 정의됩니다. 자막에 대해서는 책임을 지지 않습니다. 이 명령은 FigureTextFigure 내용인 하나의 인수를 사용합니다. 이 dowithnextbox속임수를 사용하면 여백 텍스트를 적절하게 정렬하는 데 사용되는 상자의 크기에 쉽게 접근할 수 있습니다. 이를 통해 매개변수 없이 매크로를 정의할 수 있습니다.

여백 텍스트는 두 번째 인수로 전달됩니다. \startplacefigure 그리고 를 사용하여 픽업했습니다 \floatuserdataparameter.

사용 방법의 예는 다음과 같습니다.

\showframe
\starttext
\dorecurse{2}{%%
  \startplacefigure
    [title=Some figure]
    [text=Some additional text for the margin.]
    \externalfigure
  \stopplacefigure

  \startplacefigure
    [title=Another figure]
    [text=Some more margin text for the other figure.]
    \externalfigure [dum] [width=\textwidth]
  \stopplacefigure
}
\stoptext

스크린샷1

주의사항

여백 텍스트의 높이는 고려되지 않습니다. 부동 소수점이 연속적으로 배치되면 여백 텍스트가 겹칠 수 있습니다. 예:

\starttext
\dorecurse{2}{%%
  \startplacefigure
    [title=Some figure]
    [text=\input ward\par]
    \externalfigure
  \stopplacefigure}
\stoptext

스크린샷2

관련 정보