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 所提到的,使用懸掛在這裡是錯誤的方法。在他連結到漢斯和沃爾夫岡的帖子中已經提供了兩種解決方案。我將介紹第三種解決方案,它基於 Wolfgang 的解決方案,具有以下功能:

  • 附加文字排版在頁邊空白處,而不僅僅是靠近圖形。
  • 它使用邊際數據介面。這允許使用通常的方式操作邊距文本上下文介面
  • 我試著盡可能避免低階命令。
  • 附加的圖形文字是可選的。
  • 預設情況下,附加邊距文字居中。如果其高度超過圖形高度,則它們在頂部對齊。

程式碼

\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,排版圖形內容和附加邊距文字。它不對標題負責。此指令FigureText採用一個參數,即圖形內容。該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

相關內容