Vertically Aligning inmargin Text to Figure
Hi, I need to associate a bit of text with a figure in a book. The text is not---and cannot be---the figure caption (it's providing some explanation with respect to some labels in the figure). I have tried the following based on some other post on the mailing list: \definepapersize[eightsquare][width=8in, height=8in] \setuppapersize[eightsquare] \setuplayout[ location=doublesided, marking=on, backspace=43mm, leftmargin=18mm, leftmargindistance=4mm, rightmargin=35mm, rightmargindistance=4mm, rightedgewidth=6mm, topspace=12mm, header=15mm, footer=15mm, height=179mm, width=115mm ] \starttext \startplacefigure[location=force, title={First dummy caption}] \inmargin{First margin dummy} \externalfigure[dummy][width=115mm] \stopplacefigure \stoptext However, that results in the text being down the bottom of the figure. I need the text to be vertically aligned with the top of the figure. I have attached the resulting PDF for illustration purposes (is that okay on this mailing list? It's very small). Any hints would be much appreciated. Thank you, Malte. -- “The Electric Monk was a labour-saving device, like a dishwasher or a video recorder... Electric Monks believed things for you, thus saving you what was becoming an increasingly onerous task, that of believing all the things the world expected you to believe.” ― Douglas Adams, Dirk Gently's Holistic Detective Agency
Am 29.04.2013 um 09:33 schrieb Malte Stien
Hi,
I need to associate a bit of text with a figure in a book. The text is not---and cannot be---the figure caption (it's providing some explanation with respect to some labels in the figure). I have tried the following based on some other post on the mailing list:
\definepapersize[eightsquare][width=8in, height=8in] \setuppapersize[eightsquare]
\setuplayout[ location=doublesided, marking=on, backspace=43mm, leftmargin=18mm, leftmargindistance=4mm, rightmargin=35mm, rightmargindistance=4mm, rightedgewidth=6mm, topspace=12mm, header=15mm, footer=15mm, height=179mm, width=115mm ]
\starttext
\startplacefigure[location=force, title={First dummy caption}] \inmargin{First margin dummy} \externalfigure[dummy][width=115mm] \stopplacefigure
\stoptext
However, that results in the text being down the bottom of the figure. I need the text to be vertically aligned with the top of the figure. I have attached the resulting PDF for illustration purposes (is that okay on this mailing list? It's very small).
Any hints would be much appreciated.
You can set the text in the margin with the second argument of \startplacefigure. \define\FigureText {\dowithnextbox {\startlinealignment[middle] \copy\nextbox\rlap{\hskip\rightmargindistance\framed[frame=off,width=\rightmarginwidth,height=\nextboxht]{\floatuserdataparameter{text}}} \stoplinealignment} \hbox} \setupfloat[figure][command=\FigureText] \starttext \startplacefigure[title=Dummy figure][text=Margin dummy] \externalfigure[dummy][width=.8\textwidth] \stopplacefigure \stoptext Wolfgang
Wolfgang,
Thank you for this. I can see what you are trying to do here, but this does not actually compile for me. Unfortunately, I don't know enough about the implementation of ConTeXt to track the problem down. I am getting:
! Undefined control sequence.
system > tex > error on line 14 in file test.tex: Undefined control sequence ...
4 \copy\nextbox\rlap{\hskip\rightmargindistance\framed[frame=off,width=\rightmarginwidth,height=\nextboxht]{\floatuserdataparameter{text}}}
5 \stoplinealignment}
6 \hbox}
7
8 \setupfloat[figure][command=\FigureText]
9
10 \starttext
11
12 \startplacefigure[title=Dummy figure][text=Margin dummy]
13 \externalfigure[dummy][width=.8\textwidth]
14 >> \stopplacefigure
15
16 \stoptext
17
\syst_boxes_with_next_box ->\startlinealignment
[middle] \copy \nextbox \rla...
\strc_floats_place_packaged_boxes_indeed ...tbox }
}\strc_floats_set_natural_...
\strc_floats_finish_placement ...e_packaged_boxes
\dostoptagged \global \d_p...
l.14 \stopplacefigure
Admittedly, I am on version 2012.10.20, which is about six months old now, but I am hesitant to update as I have a lot of co-workers using the same version and our configuration management processes dictate that we always update together.
Could you please help me out.
Thank you,
Malte.
--
“The Electric Monk was a labour-saving device, like a dishwasher or a video recorder... Electric Monks believed things for you, thus saving you what was becoming an increasingly onerous task, that of believing all the things the world expected you to believe.”
― Douglas Adams, Dirk Gently's Holistic Detective Agency
On 29/04/2013, at 9:04 PM, Wolfgang Schuster
Am 29.04.2013 um 09:33 schrieb Malte Stien
: Hi,
I need to associate a bit of text with a figure in a book. The text is not---and cannot be---the figure caption (it's providing some explanation with respect to some labels in the figure). I have tried the following based on some other post on the mailing list:
\definepapersize[eightsquare][width=8in, height=8in] \setuppapersize[eightsquare]
\setuplayout[ location=doublesided, marking=on, backspace=43mm, leftmargin=18mm, leftmargindistance=4mm, rightmargin=35mm, rightmargindistance=4mm, rightedgewidth=6mm, topspace=12mm, header=15mm, footer=15mm, height=179mm, width=115mm ]
\starttext
\startplacefigure[location=force, title={First dummy caption}] \inmargin{First margin dummy} \externalfigure[dummy][width=115mm] \stopplacefigure
\stoptext
However, that results in the text being down the bottom of the figure. I need the text to be vertically aligned with the top of the figure. I have attached the resulting PDF for illustration purposes (is that okay on this mailing list? It's very small).
Any hints would be much appreciated.
You can set the text in the margin with the second argument of \startplacefigure.
\define\FigureText {\dowithnextbox {\startlinealignment[middle] \copy\nextbox\rlap{\hskip\rightmargindistance\framed[frame=off,width=\rightmarginwidth,height=\nextboxht]{\floatuserdataparameter{text}}} \stoplinealignment} \hbox}
\setupfloat[figure][command=\FigureText]
\starttext
\startplacefigure[title=Dummy figure][text=Margin dummy] \externalfigure[dummy][width=.8\textwidth] \stopplacefigure
\stoptext
Wolfgang ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
On 5/24/2013 8:46 AM, Malte Stien wrote:
Wolfgang,
Thank you for this. I can see what you are trying to do here, but this does not actually compile for me. Unfortunately, I don't know enough about the implementation of ConTeXt to track the problem down. I am getting:
! Undefined control sequence.
system > tex > error on line 14 in file test.tex: Undefined control sequence ...
4 \copy\nextbox\rlap{\hskip\rightmargindistance\framed[frame=off,width=\rightmarginwidth,height=\nextboxht]{\floatuserdataparameter{text}}} 5 \stoplinealignment} 6 \hbox} 7 8 \setupfloat[figure][command=\FigureText] 9 10 \starttext 11 12 \startplacefigure[title=Dummy figure][text=Margin dummy] 13 \externalfigure[dummy][width=.8\textwidth] 14 >> \stopplacefigure 15 16 \stoptext 17
\syst_boxes_with_next_box ->\startlinealignment [middle] \copy \nextbox \rla... \strc_floats_place_packaged_boxes_indeed ...tbox } }\strc_floats_set_natural_... \strc_floats_finish_placement ...e_packaged_boxes \dostoptagged \global \d_p... l.14 \stopplacefigure
Admittedly, I am on version 2012.10.20, which is about six months old now, but I am hesitant to update as I have a lot of co-workers using the same version and our configuration management processes dictate that we always update together.
Could you please help me out.
you can do a fresh install alongside an existing one and then run some tests Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Am 24.05.2013 um 08:46 schrieb Malte Stien
Wolfgang,
Thank you for this. I can see what you are trying to do here, but this does not actually compile for me. Unfortunately, I don't know enough about the implementation of ConTeXt to track the problem down. I am getting:
! Undefined control sequence.
system > tex > error on line 14 in file test.tex: Undefined control sequence ...
4 \copy\nextbox\rlap{\hskip\rightmargindistance\framed[frame=off,width=\rightmarginwidth,height=\nextboxht]{\floatuserdataparameter{text}}} 5 \stoplinealignment} 6 \hbox} 7 8 \setupfloat[figure][command=\FigureText] 9 10 \starttext 11 12 \startplacefigure[title=Dummy figure][text=Margin dummy] 13 \externalfigure[dummy][width=.8\textwidth] 14 >> \stopplacefigure 15 16 \stoptext 17
\syst_boxes_with_next_box ->\startlinealignment [middle] \copy \nextbox \rla... \strc_floats_place_packaged_boxes_indeed ...tbox } }\strc_floats_set_natural_... \strc_floats_finish_placement ...e_packaged_boxes \dostoptagged \global \d_p... l.14 \stopplacefigure
Admittedly, I am on version 2012.10.20, which is about six months old now, but I am hesitant to update as I have a lot of co-workers using the same version and our configuration management processes dictate that we always update together.
Could you please help me out.
You can replace \startlinealignment … \stoplinealignment with \midaligned: \define\FigureText {\dowithnextbox {\scratchdimen\nextboxht \midaligned\bgroup \flushnextbox\rlap{\hskip\rightmargindistance\framed[frame=off,width=\rightmarginwidth,height=\scratchdimen]{\floatuserdataparameter{text}}} \egroup} \hbox} Wolfgang
Wolfgang, I have to come back to this solution you provided me with some time ago. I have more reading in the meantime and have gained a deeper understanding of how this actually works. However... 1. I noticed that the text in the margin is not actually quite aligned with the top of the figure; I think the text starts at the baseline of the line that would be there if the figure was not, if you know what I am getting at. That is at 12pt font size the text is about 12pt below the top of the figure. I tried to fix that with some negative \vskip, but that does not seem to work. Could you suggest an alternative please and maybe even explain why the code below does not compile
You can set the text in the margin with the second argument of \startplacefigure.
\define\FigureText {\dowithnextbox {\startlinealignment[middle] \copy\nextbox\rlap{\hskip\rightmargindistance\vskip-12pt\framed[frame=off,width=\rightmarginwidth,height=\nextboxht]{\floatuserdataparameter{text}}} \stoplinealignment} \hbox}
2. Currently the code always uses the right margin; I need it to use the outer margin. I experimented swapping the \rlap for \llap, but then I still have to negatively \hskip the entire text width to the left. Even if I got that to work, I will have to wrap everything in an if-statement and have one branch for left and one for right pages. Right? How do I find out whether I am on a left or a right page? In other words, how would the if-statement look like.
Thank you,
Malte.
--
“The Electric Monk was a labour-saving device, like a dishwasher or a video recorder... Electric Monks believed things for you, thus saving you what was becoming an increasingly onerous task, that of believing all the things the world expected you to believe.”
― Douglas Adams, Dirk Gently's Holistic Detective Agency
On 29/04/2013, at 9:04 PM, Wolfgang Schuster
Am 29.04.2013 um 09:33 schrieb Malte Stien
: Hi,
I need to associate a bit of text with a figure in a book. The text is not---and cannot be---the figure caption (it's providing some explanation with respect to some labels in the figure). I have tried the following based on some other post on the mailing list:
\definepapersize[eightsquare][width=8in, height=8in] \setuppapersize[eightsquare]
\setuplayout[ location=doublesided, marking=on, backspace=43mm, leftmargin=18mm, leftmargindistance=4mm, rightmargin=35mm, rightmargindistance=4mm, rightedgewidth=6mm, topspace=12mm, header=15mm, footer=15mm, height=179mm, width=115mm ]
\starttext
\startplacefigure[location=force, title={First dummy caption}] \inmargin{First margin dummy} \externalfigure[dummy][width=115mm] \stopplacefigure
\stoptext
However, that results in the text being down the bottom of the figure. I need the text to be vertically aligned with the top of the figure. I have attached the resulting PDF for illustration purposes (is that okay on this mailing list? It's very small).
Any hints would be much appreciated.
You can set the text in the margin with the second argument of \startplacefigure.
\define\FigureText {\dowithnextbox {\startlinealignment[middle] \copy\nextbox\rlap{\hskip\rightmargindistance\framed[frame=off,width=\rightmarginwidth,height=\nextboxht]{\floatuserdataparameter{text}}} \stoplinealignment} \hbox}
\setupfloat[figure][command=\FigureText]
\starttext
\startplacefigure[title=Dummy figure][text=Margin dummy] \externalfigure[dummy][width=.8\textwidth] \stopplacefigure
\stoptext
Wolfgang ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
On 6/18/2013 6:11 AM, Malte Stien wrote:
Wolfgang,
I have to come back to this solution you provided me with some time ago. I have more reading in the meantime and have gained a deeper understanding of how this actually works. However...
1. I noticed that the text in the margin is not actually quite aligned with the top of the figure; I think the text starts at the baseline of the line that would be there if the figure was not, if you know what I am getting at. That is at 12pt font size the text is about 12pt below the top of the figure. I tried to fix that with some negative \vskip, but that does not seem to work. Could you suggest an alternative please and maybe even explain why the code below does not compile
You can set the text in the margin with the second argument of \startplacefigure.
\define\FigureText {\dowithnextbox {\startlinealignment[middle] \copy\nextbox\rlap{\hskip\rightmargindistance\vskip-12pt\framed[frame=off,width=\rightmarginwidth,height=\nextboxht]{\floatuserdataparameter{text}}} \stoplinealignment} \hbox}
2. Currently the code always uses the right margin; I need it to use the outer margin. I experimented swapping the \rlap for \llap, but then I still have to negatively \hskip the entire text width to the left. Even if I got that to work, I will have to wrap everything in an if-statement and have one branch for left and one for right pages. Right? How do I find out whether I am on a left or a right page? In other words, how would the if-statement look like.
\setuppagenumbering[alternative=doublesided] \starttext \definelayer [extrafiguretextlayer:l] [width=\overlaywidth, height=\overlayheight, corner={right,top}, location={right,bottom}, x=-1cm] \definelayer [extrafiguretextlayer:r] [width=\overlaywidth, height=\overlayheight, corner={left,top}, location={left,bottom}, x=-1cm] \startsetups extrafiguretext \signalouterrealign \setlayerframed [extrafiguretextlayer:\rightorleftpageaction rl] [] [width=\marginwidth, align={lohi,middle}, foregroundstyle=\tx] {\floatuserdataparameter{text}} \flushlayer [extrafiguretextlayer:\rightorleftpageaction rl] \stopsetups \defineoverlay [extrafiguretext] [\setups{extrafiguretext}] \setupfloat [figure] [background={foreground,extrafiguretext}] \dorecurse {20} { \startplacefigure[title=Dummy figure][text={margin dummy text #1}] \externalfigure[dummy][width=.8\textwidth] \stopplacefigure } \stoptext
Thank you, Malte.
-- “The Electric Monk was a labour-saving device, like a dishwasher or a video recorder... Electric Monks believed things for you, thus saving you what was becoming an increasingly onerous task, that of believing all the things the world expected you to believe.”
― Douglas Adams, Dirk Gently's Holistic Detective Agency
On 29/04/2013, at 9:04 PM, Wolfgang Schuster
wrote: Am 29.04.2013 um 09:33 schrieb Malte Stien
: Hi,
I need to associate a bit of text with a figure in a book. The text is not---and cannot be---the figure caption (it's providing some explanation with respect to some labels in the figure). I have tried the following based on some other post on the mailing list:
\definepapersize[eightsquare][width=8in, height=8in] \setuppapersize[eightsquare]
\setuplayout[ location=doublesided, marking=on, backspace=43mm, leftmargin=18mm, leftmargindistance=4mm, rightmargin=35mm, rightmargindistance=4mm, rightedgewidth=6mm, topspace=12mm, header=15mm, footer=15mm, height=179mm, width=115mm ]
\starttext
\startplacefigure[location=force, title={First dummy caption}] \inmargin{First margin dummy} \externalfigure[dummy][width=115mm] \stopplacefigure
\stoptext
However, that results in the text being down the bottom of the figure. I need the text to be vertically aligned with the top of the figure. I have attached the resulting PDF for illustration purposes (is that okay on this mailing list? It's very small).
Any hints would be much appreciated.
You can set the text in the margin with the second argument of \startplacefigure.
\define\FigureText {\dowithnextbox {\startlinealignment[middle] \copy\nextbox\rlap{\hskip\rightmargindistance\framed[frame=off,width=\rightmarginwidth,height=\nextboxht]{\floatuserdataparameter{text}}} \stoplinealignment} \hbox}
\setupfloat[figure][command=\FigureText]
\starttext
\startplacefigure[title=Dummy figure][text=Margin dummy] \externalfigure[dummy][width=.8\textwidth] \stopplacefigure
\stoptext
Wolfgang ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
-- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Am 18.06.2013 um 06:11 schrieb Malte Stien
2. Currently the code always uses the right margin; I need it to use the outer margin. I experimented swapping the \rlap for \llap, but then I still have to negatively \hskip the entire text width to the left. Even if I got that to work, I will have to wrap everything in an if-statement and have one branch for left and one for right pages. Right? How do I find out whether I am on a left or a right page? In other words, how would the if-statement look like.
\define\FigureText {\dowithnextbox {\signalrightpage \doifrightpageelse\donetrue\donefalse \scratchdimen\nextboxht \hbox\bgroup \ifdone \midaligned{\flushnextbox}\rlap{\hskip\rightmargindistance\framed[frame=off,width=\rightmarginwidth,height=\scratchdimen]{\floatuserdataparameter{text}}}% \else \llap{\framed[frame=off,width=\rightmarginwidth,height=\scratchdimen]{\floatuserdataparameter{text}}\hskip\leftmargindistance}\midaligned{\flushnextbox}% \fi \egroup} \hbox} \setupfloat[figure][command=\FigureText] \setuppagenumbering[alternative=doublesided] \starttext \showgrid \dorecurse{4}{\input knuth\par} \startplacefigure[title=Dummy figure][text=Margin dummy] \externalfigure[dummy][width=.8\textwidth] \stopplacefigure \dorecurse{4}{\input knuth\par} \startplacefigure[title=Dummy figure][text=Margin dummy] \externalfigure[dummy][width=.8\textwidth] \stopplacefigure \dorecurse{4}{\input knuth\par} \startplacefigure[title=Dummy figure][text=Margin dummy] \externalfigure[dummy][width=.8\textwidth] \stopplacefigure \dorecurse{4}{\input knuth\par} \startplacefigure[title=Dummy figure][text=Margin dummy] \externalfigure[dummy][width=.8\textwidth] \stopplacefigure \dorecurse{4}{\input knuth\par} \stoptext Wolfgang
participants (3)
-
Hans Hagen
-
Malte Stien
-
Wolfgang Schuster