我使用了 Mikep 的技术ConTeXt:如何让正文位于页边距底部浮动标题的旁边?但现在我想要将浮动图像放在顶部,将文本放在左边缘下方。StanleyL 层似乎很小,位于左边缘的顶部。因此,我无法通过更改层的角或位置将边缘文本移到图像下方。请参阅屏幕截图和 MEW1。
问题 1 - 我可以将图层 StanleyL 移动到图像下方吗?
如果没有,我可以使用图像的尺寸来计算文本顶部的位置。由于图像在放置时会缩放,因此我需要计算 \fullwidth x \figureheight / \figurewidth。我尝试使用 dimexprs 和 numexprs,但它们不起作用。我尝试了一些 lua,当我输入整数时它可以工作,但当我输入像 \figurewidth 这样的数字时它会失败。MWE2。
问题 2 - 如何计算放置图像时的高度?
\showframe
\setuppapersize[A4][A3,landscape] \setuparranging[2SIDE]
\setupalign[height]
\setuplayout[backspace=80mm, width=100mm, topspace=50mm, header=0mm, footer=0mm, height=200mm, margindistance=10mm, leftmargin=40mm]
\newdimen\fullwidth % margin + main text
\fullwidth= \dimexpr(\leftmarginwidth+\leftmargindistance + \makeupwidth)
\setupexternalfigures[location=default]
\definefloat[bottomfigure][figure][
default={top,none},
location=innermargin,
]
\setupcaption[figure][style=small,]
\defineframed[captionframed]
[align={flushleft}, width=40mm, offset=overlay, boffset=\lineheight, frame=on, ]
\definelayer[StanleyL]
\setuplayer[StanleyL][corner=lefttop,location={right,top},]
\defineexternalfigure[StanleyF][externalfigure][background=StanleyL,]
\starttext
\startplacebottomfigure
\setlayer[StanleyL]{\captionframed{\placefloatcaption[figure][title={This is the caption of the cow picture}]}}
\externalfigure[cow][StanleyF][width=\fullwidth]
\stopplacebottomfigure
\dorecurse{3}{{\darkblue\samplefile{knuth}}\par}
\stoptext
MWE2:
\setupexternalfigures[location=default]
\def\myheight#1#2#3%
{\ctxlua{context(#1 * #2 / #3)}}
\starttext
\getfiguredimensions[cow]
\figureheight---\figurewidth---\the\textwidth
% this works, but not if I pass it \figurewidth or context.figurewidth
\myheight {3}{8}{4}
\stoptext
答案1
我以为这个答案已经更新了,但无论如何。也许这是一个起点?(我不知道如何摆脱/配置牛下面的空间。)
关于问题2,我不知道/不明白您想做什么。
\showframe
\setuppapersize[A4][A3,landscape] \setuparranging[2SIDE]
\setupalign[height]
\setuplayout
[backspace=80mm,
width=100mm,
topspace=50mm,
header=0mm,
footer=0mm,
height=200mm,
margindistance=10mm,
leftmargin=40mm]
\setupexternalfigures[location=default]
\setupcaptions
[width=\leftmarginwidth,
align={width,hanging},
style={\tfx\setupinterlinespace}]
\definefloat
[top]
[figure]
[default={top},
location=leftmargin]
\setupcaption
[top]
[location={bottom,overlay}]
\defineexternalfigure
[full]
[width=\dimexpr\leftmargintotal+\textwidth\relax]
\starttext
\dorecurse{3}{\samplefile{douglas}\par}
\startplacefloat
[top]
[title={\samplefile{ward}\par}]
\externalfigure[cow][full]
\stopplacefloat
\dorecurse{3}{\samplefile{knuth}\par}
\stoptext
答案2
我最终还是这么做了,这样我就可以对顶部和底部浮动使用相同的机制。如果 ConTeXt 决定将浮动推到后面的页面,则会出现几个问题:
1 - 标题在错误的页面上。您可能可以通过设置来修复此问题,如 mikep 在此处所述ConTeXt:如何让正文位于页边距底部浮动标题的旁边?
2 - 底部浮动可能会变成顶部浮动。标题在边距中的位置错误!
\showframe
\setupexternalfigures[location=default] % get the cow
\setupalign[height] % need so floats at bottom reach the bottom !
\definepapersize[mypage][height=260mm, width=185mm]
\setuppapersize[mypage]
\setuplayout
[backspace=58mm, width=106mm, leftmargin=32mm, leftmargindistance=5mm,
topspace=20mm, height=220mm, footer=5mm, footerdistance=5mm,header=0mm]
\newdimen\fullwidth % margin + main text
\fullwidth= \dimexpr(\leftmargintotal + \makeupwidth)
% the layer
\definelayer[mylayer][width=\fullwidth, height=\textheight]
\setupbackgrounds[text] [leftmargin]
[background=mylayer,state=repeat,]% seems redundant
\newdimen\figurecaptiongap \figurecaptiongap= 3mm % from figure to caption
\defineframedtext[margincaption][frame=on, location=top, offset=0mm, align={flushleft}, style={\ss\switchtobodyfont[9pt]}, width=\leftmarginwidth]
\defineexternalfigure [fullwidthfigure][width=\fullwidth]
\getfiguredimensions % enable \figureheight, set after each \externalfigure
% the float figure
\definefloat[fullwidthfloat][figure]
[location=leftmargin,]
% 1 = must be top or bottom, 2 = image, 3 = text
\define[3]\macfloatfullwidth
{
\startplacefloat [fullwidthfloat][location={#1,none}]% must do float before caption
\externalfigure[#2][fullwidthfigure]
\stopplacefloat
\setlayer[mylayer]
[preset=left#1, voffset=\figureheight + \figurecaptiongap]
{\margincaption[]{#3} }
}
\starttext
\dorecurse{1}{\input tufte}
\macfloatfullwidth {top}{cow}{This is a cow}
\dorecurse{2}{\input tufte}
\macfloatfullwidth {bottom}{hacker}{These are hackers busy hacking}
\dorecurse{4}{\input tufte}
\stoptext