
ConTeXT を使用して、追加のサイドテキストを含む複数の図を次々に配置しようとしています。
2 つの図形が一列に並んでいる場合、それらは重なっています。どのように分離すればよいでしょうか。
次のコードは、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 がすでに 2 つのソリューションを提供しています。Wolfgang のソリューションに基づいて、次の機能を備えた 3 番目のソリューションを紹介します。
- 追加のテキストは、図の近くだけでなく、余白にタイプセットされます。
- 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
次に、図の内容と追加の余白テキストをタイプセットするコマンドが定義されます。このコマンドはキャプションには関与しません。このコマンドはFigureText
、図の内容である 1 つの引数を取ります。このdowithnextbox
トリックにより、余白テキストを適切に配置するために使用されるボックスの寸法に簡単にアクセスできます。これにより、パラメーターなしでマクロを定義できます。
余白テキストは2番目の引数として渡されます
\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
注意点
余白テキストの高さは考慮されません。フロートを連続して配置すると、余白テキストが重なる可能性があります。例:
\starttext
\dorecurse{2}{%%
\startplacefigure
[title=Some figure]
[text=\input ward\par]
\externalfigure
\stopplacefigure}
\stoptext