![调整 ConTeXt 中自定义浮点数的标签文本和计数器?](https://linux22.com/image/342547/%E8%B0%83%E6%95%B4%20ConTeXt%20%E4%B8%AD%E8%87%AA%E5%AE%9A%E4%B9%89%E6%B5%AE%E7%82%B9%E6%95%B0%E7%9A%84%E6%A0%87%E7%AD%BE%E6%96%87%E6%9C%AC%E5%92%8C%E8%AE%A1%E6%95%B0%E5%99%A8%EF%BC%9F.png)
我目前正在从事一个图书项目,最近决定改用 ConTeXt(来自 LaTeX)。在重新编码我已经在 LaTeX 中设置的内容的过程中,我现在遇到了我认为我遗漏了的简单切换。所以,我希望这个平台上的某个人可以提供一些帮助。
以下是我正在研究的 MWE(讨论了这个研究的基础这里):
\usemodule[visual]
\enableregime [utf-8]
\mainlanguage[de]
\language[de]
\definecolor[lightbrown] [r=0.83, g=0.76, b=0.71]
\setuppapersize[A4][A4]
\setuplayout
[
backspace=11.67mm, width=131.25mm,
topspace=21.21mm, height=254.57mm,
headerdistance=13pt, header=13pt,
footerdistance=13pt, footer=13pt,
rightmargindistance=13pt, rightmargin=39.5mm,
]
\setuppagenumbering[alternative=doublesided, location=]
\definemeasure[fullwidth][\dimexpr\textwidth+\outermarginwidth+\outermargindistance\relax]
\definefloat[widefloat][widefloats]
\setupfloat[widefloat][
location=inner,
width=\measure{fullwidth},
default={here, top},
]
\setupcaption[widefloat][
width=max,
location=bottom,
headstyle=\ss\bf,
style=\tf\it,
align=flushleft,
spaceafter=\lineheight,
]
\definefloat[sidefloat][sidefloats]
\setupfloat[sidefloat][
width=\outermarginwidth,
default=outermargin,
]
\setupcaption[sidefloat][
width=max,
location=bottom,
headstyle=\ss\bf,
style=\tf\it,
align=flushleft,
]
\def\WideFigure#1#2%
{\placewidefloat[here, top]{#2}{\framed[width=\measure{fullwidth}, background=color, backgroundcolor=lightbrown]{#1}}}
\def\SideFigure#1#2%
{\placesidefloat[outermargin]{#2}{\framed[width=\outermarginwidth, background=color, backgroundcolor=lightbrown]{#1}}}
\starttext
\chapter{\fakewords{2}{3}}
\fakewords{50}{60}
\fakewords{50}{60}
\WideFigure{This is a wide (external) figure.}{And this is its caption.}
\fakewords{50}{60}
\fakewords{50}{60}
\SideFigure{Side figure.}{And its caption.}
\fakewords{50}{60}
\fakewords{50}{60}
\stoptext
如您所见,我设置了两种不同的浮动:(widefloat
和相关定义WideFigure
)用于横向格式的(外部)图形,将跨越文本区域和外边距区域。另一方面, sidefloat
(和SideFigure
)表示将定位在外边距中的小图形。这效果相当好,大致如下所示:
但是,这个解决方案仍然有两个问题:首先,两种浮点数现在有两个单独的计数器,因此现在有两个具有相同数字的不同数字。有没有办法让两个浮点数使用相同的计数器? 或者更好的是:我可以让所有包含外部图形的自定义浮点数使用与原始浮点数相同的计数器吗?
第二个问题是,我的自定义浮点数现在标有其内部名称。我想更改标签将“Widefloat”和“Sidefloat”改为“Figure”。这样可以吗?
任何帮助将非常感激。
答案1
您的设置中只是缺少一个可以解决这两个问题的参数。\definefloat
采用第三个可选参数来设置父母浮动。如果你将父级设置为figure
,则标签和计数器将从中获取figure
。因此,你只需要:
\definefloat[widefloat][widefloats][figure]
\definefloat[sidefloat][sidefloats][figure]
这是一个完整的例子(请注意,我删除了它,\enableregime[utf-8]
因为 MkIV 中不需要它。
\usemodule[visual]
\mainlanguage[de]
\language[de]
\definecolor[lightbrown] [r=0.83, g=0.76, b=0.71]
\setuppapersize[A4][A4]
\setuplayout
[
backspace=11.67mm, width=131.25mm,
topspace=21.21mm, height=254.57mm,
headerdistance=13pt, header=13pt,
footerdistance=13pt, footer=13pt,
rightmargindistance=13pt, rightmargin=39.5mm,
]
\setuppagenumbering[alternative=doublesided, location=]
\definemeasure[fullwidth][\dimexpr\textwidth+\outermarginwidth+\outermargindistance\relax]
\definefloat[widefloat][widefloats][figure]
\setupfloat[widefloat]
[
location=inner,
width=\measure{fullwidth},
default={here, top},
]
\setupcaption[widefloat]
[
width=max,
location=bottom,
headstyle=\ss\bf,
style=\tf\it,
align=flushleft,
spaceafter=\lineheight,
]
\definefloat[sidefloat][sidefloats][figure]
\setupfloat[sidefloat]
[
width=\outermarginwidth,
default=outermargin,
]
\setupcaption[sidefloat]
[
width=max,
location=bottom,
headstyle=\ss\bf,
style=\tf\it,
align=flushleft,
]
\def\WideFigure#1#2%
{\placewidefloat[here, top]{#2}{\framed[width=\measure{fullwidth}, background=color, backgroundcolor=lightbrown]{#1}}}
\def\SideFigure#1#2%
{\placesidefloat[outermargin]{#2}{\framed[width=\outermarginwidth, background=color, backgroundcolor=lightbrown]{#1}}}
\starttext
\chapter{\fakewords{2}{3}}
\fakewords{50}{60}
\fakewords{50}{60}
\WideFigure{This is a wide (external) figure.}{And this is its caption.}
\fakewords{50}{60}
\fakewords{50}{60}
\SideFigure{Side figure.}{And its caption.}
\fakewords{50}{60}
\fakewords{50}{60}
\stoptext
这使
请注意,由于您已设置\mainlanguage[de]
,因此图形(Abbildung)的标签文本是德语。