How to make floats extend into the outer margin
Dear list, I have some big-width floats, and want them to span the regular text width plus the outer margin. I can position them manually with \kern. Is there a way to make them automatically extend into the outer margin? I have tried different options for location=... without success. Thanks and kind regards, Joshua Krämer Example with manual positioning: \setuplayout [backspace=3cm, width=13.5cm, topspace=2cm, height=24.7cm, margin=1.5cm, margindistance=0cm, header=0cm, footer=0cm, footerdistance=0cm] \newdimen\Bigtextwidth \Bigtextwidth=15cm \setuppagenumbering [alternative=doublesided] \showframe \starttext \startplacefigure \leavevmode\kern-1.5cm\framed [width=\Bigtextwidth, framecolor=red] % {Left margin} \stopplacefigure \startplacefigure \leavevmode\kern0cm\framed [width=\Bigtextwidth, framecolor=red] % {Right margin} \stopplacefigure \stoptext
Am 23.07.2014 um 17:48 schrieb Joshua Krämer
Dear list,
I have some big-width floats, and want them to span the regular text width plus the outer margin. I can position them manually with \kern. Is there a way to make them automatically extend into the outer margin? I have tried different options for location=... without success.
Thanks and kind regards, Joshua Krämer
Example with manual positioning:
\setuplayout [backspace=3cm, width=13.5cm, topspace=2cm, height=24.7cm, margin=1.5cm, margindistance=0cm, header=0cm, footer=0cm, footerdistance=0cm]
\newdimen\Bigtextwidth \Bigtextwidth=15cm
\setuppagenumbering [alternative=doublesided]
\showframe
\starttext
\startplacefigure \leavevmode\kern-1.5cm\framed [width=\Bigtextwidth, framecolor=red] % {Left margin} \stopplacefigure
\startplacefigure \leavevmode\kern0cm\framed [width=\Bigtextwidth, framecolor=red] % {Right margin} \stopplacefigure
\stoptext
You can use the command key for \setupfloat to apply a macro to the finished content of the float. The purpose of this macro is to save the content and compare the width to the width of the text are, when the figure is wider then the available space use the \leftaligned or \rightaligned commands to let the content protrude to the outer margins. \setuppagenumbering[alternative=doublesided] \setuplayout[backspace=4cm,width=12cm] \definemeasure[Widefigure][\textwidth+\rightmargindistance+\rightmarginwidth] \setupfloat[figure][command=\FigureCommand] \define\FigureCommand {\dowithnextbox {\signalrightpage \ifdim\nextboxwd>\textwidth \doifrightpageelse{\leftaligned{\flushnextbox}}{\rightaligned{\flushnextbox}}% \else \midaligned{\flushnextbox}% \fi} \hbox} \showframe \starttext \startplacefigure \framed[width=.8\textwidth,framecolor=red]{Left margin} \stopplacefigure \page \startplacefigure \framed[width=\measure{Widefigure},framecolor=red]{Left margin} \stopplacefigure \input knuth \page \startplacefigure \framed[width=\measure{Widefigure},framecolor=red]{Right margin} \stopplacefigure \stoptext Wolfgang
Hello,
I assume others might have need for this, so it might be a good idea to put this into the
core with a name of something like \widefigure or \ placewidefigure!
Just, a thought!
regards
Keith.
Am 24.07.2014 um 10:36 schrieb Wolfgang Schuster
Am 23.07.2014 um 17:48 schrieb Joshua Krämer
: Dear list,
I have some big-width floats, and want them to span the regular text width plus the outer margin. I can position them manually with \kern. Is there a way to make them automatically extend into the outer margin? I have tried different options for location=... without success.
{snip, snip}
You can use the command key for \setupfloat to apply a macro to the finished content of the float.
The purpose of this macro is to save the content and compare the width to the width of the text are, when the figure is wider then the available space use the \leftaligned or \rightaligned commands to let the content protrude to the outer margins.
\setuppagenumbering[alternative=doublesided]
\setuplayout[backspace=4cm,width=12cm]
\definemeasure[Widefigure][\textwidth+\rightmargindistance+\rightmarginwidth]
\setupfloat[figure][command=\FigureCommand]
\define\FigureCommand {\dowithnextbox {\signalrightpage \ifdim\nextboxwd>\textwidth \doifrightpageelse{\leftaligned{\flushnextbox}}{\rightaligned{\flushnextbox}}% \else \midaligned{\flushnextbox}% \fi} \hbox}
\showframe
\starttext
\startplacefigure \framed[width=.8\textwidth,framecolor=red]{Left margin} \stopplacefigure
\page
\startplacefigure \framed[width=\measure{Widefigure},framecolor=red]{Left margin} \stopplacefigure
\input knuth
\page
\startplacefigure \framed[width=\measure{Widefigure},framecolor=red]{Right margin} \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 7/24/2014 3:41 PM, Keith J. Schultz wrote:
Hello,
I assume others might have need for this, so it might be a good idea to put this into the core with a name of something like \widefigure or \ placewidefigure!
Just, a thought!
regards Keith.
Am 24.07.2014 um 10:36 schrieb Wolfgang Schuster
mailto:schuster.wolfgang@gmail.com>: Am 23.07.2014 um 17:48 schrieb Joshua Krämer
mailto:joshua.kraemer@gmail.com>: Dear list,
I have some big-width floats, and want them to span the regular text width plus the outer margin. I can position them manually with \kern. Is there a way to make them automatically extend into the outer margin? I have tried different options for location=... without success.
{snip, snip}
\starttext \startplacefigure \framed[width=.8\textwidth,framecolor=red]{one} \stopplacefigure \setupfloat[figure][location=flushleft] \startplacefigure \framed[width=1.2\textwidth,framecolor=blue]{two} \stopplacefigure \stoptext
You can use the command key for \setupfloat to apply a macro to the finished content of the float.
The purpose of this macro is to save the content and compare the width to the width of the text are, when the figure is wider then the available space use the \leftaligned or \rightaligned commands to let the content protrude to the outer margins.
\setuppagenumbering[alternative=doublesided]
\setuplayout[backspace=4cm,width=12cm]
\definemeasure[Widefigure][\textwidth+\rightmargindistance+\rightmarginwidth]
\setupfloat[figure][command=\FigureCommand]
\define\FigureCommand {\dowithnextbox {\signalrightpage \ifdim\nextboxwd>\textwidth \doifrightpageelse{\leftaligned{\flushnextbox}}{\rightaligned{\flushnextbox}}% \else \midaligned{\flushnextbox}% \fi} \hbox}
\showframe
\starttext
\startplacefigure \framed[width=.8\textwidth,framecolor=red]{Left margin} \stopplacefigure
\page
\startplacefigure \framed[width=\measure{Widefigure},framecolor=red]{Left margin} \stopplacefigure
\input knuth
\page
\startplacefigure \framed[width=\measure{Widefigure},framecolor=red]{Right margin} \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 mailto: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 -----------------------------------------------------------------
On 2014-07-25 07:10, Hans Hagen wrote:
Am 24.07.2014 um 10:36 schrieb Wolfgang Schuster
mailto:schuster.wolfgang@gmail.com>: \starttext
\startplacefigure \framed[width=.8\textwidth,framecolor=red]{one} \stopplacefigure
\setupfloat[figure][location=flushleft]
\startplacefigure \framed[width=1.2\textwidth,framecolor=blue]{two} \stopplacefigure
\stoptext
You can use the command key for \setupfloat to apply a macro to the finished content of the float.
The purpose of this macro is to save the content and compare the width to the width of the text are, when the figure is wider then the available space use the \leftaligned or \rightaligned commands to let the content protrude to the outer margins.
\setuppagenumbering[alternative=doublesided]
\setuplayout[backspace=4cm,width=12cm]
\definemeasure[Widefigure][\textwidth+\rightmargindistance+\rightmarginwidth]
\setupfloat[figure][command=\FigureCommand]
\define\FigureCommand {\dowithnextbox {\signalrightpage \ifdim\nextboxwd>\textwidth \doifrightpageelse{\leftaligned{\flushnextbox}}{\rightaligned{\flushnextbox}}% \else \midaligned{\flushnextbox}% \fi} \hbox}
\showframe
\starttext
\startplacefigure \framed[width=.8\textwidth,framecolor=red]{Left margin} \stopplacefigure
\page
\startplacefigure \framed[width=\measure{Widefigure},framecolor=red]{Left margin} \stopplacefigure
\input knuth
\page
\startplacefigure \framed[width=\measure{Widefigure},framecolor=red]{Right margin} \stopplacefigure
\stoptext
Wolfgang ___________________________________________________________________________________
With Wolfgang's solution, the captions remain centered on the page. With Hans's solution, the captions move with the center of the frame. I expect that, if captions are used and there are other figures that are not placed with this mechanism, Wolfgang's solution will result in a better looking page.
-- Rik
On 7/25/2014 4:06 PM, Rik Kabel wrote:
On 2014-07-25 07:10, Hans Hagen wrote:
Am 24.07.2014 um 10:36 schrieb Wolfgang Schuster
mailto:schuster.wolfgang@gmail.com>: \starttext
\startplacefigure \framed[width=.8\textwidth,framecolor=red]{one} \stopplacefigure
\setupfloat[figure][location=flushleft]
\startplacefigure \framed[width=1.2\textwidth,framecolor=blue]{two} \stopplacefigure
\stoptext
You can use the command key for \setupfloat to apply a macro to the finished content of the float.
The purpose of this macro is to save the content and compare the width to the width of the text are, when the figure is wider then the available space use the \leftaligned or \rightaligned commands to let the content protrude to the outer margins.
\setuppagenumbering[alternative=doublesided]
\setuplayout[backspace=4cm,width=12cm]
\definemeasure[Widefigure][\textwidth+\rightmargindistance+\rightmarginwidth]
\setupfloat[figure][command=\FigureCommand]
\define\FigureCommand {\dowithnextbox {\signalrightpage \ifdim\nextboxwd>\textwidth \doifrightpageelse{\leftaligned{\flushnextbox}}{\rightaligned{\flushnextbox}}%
\else \midaligned{\flushnextbox}% \fi} \hbox}
\showframe
\starttext
\startplacefigure \framed[width=.8\textwidth,framecolor=red]{Left margin} \stopplacefigure
\page
\startplacefigure \framed[width=\measure{Widefigure},framecolor=red]{Left margin} \stopplacefigure
\input knuth
\page
\startplacefigure \framed[width=\measure{Widefigure},framecolor=red]{Right margin} \stopplacefigure
\stoptext
Wolfgang ___________________________________________________________________________________
With Wolfgang's solution, the captions remain centered on the page. With Hans's solution, the captions move with the center of the frame. I expect that, if captions are used and there are other figures that are not placed with this mechanism, Wolfgang's solution will result in a better looking page.
maybe some day i come up with a cleaner caption handler ... \showframe \starttext \startplacefigure \framed[width=.8\textwidth,framecolor=red]{one} \stopplacefigure \definefloat[widefigure][figure][figure] \setupfloat [widefigure][location=flushleft] \setupcaptions[widefigure][width=\textwidth,align=middle] \startplacewidefigure \framed[width=1.2\textwidth,framecolor=blue]{two} \stopplacewidefigure \stoptext ----------------------------------------------------------------- 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 -----------------------------------------------------------------
On 2014-07-25, 16:18, Hans Hagen wrote:
\showframe
\starttext
\startplacefigure \framed[width=.8\textwidth,framecolor=red]{one} \stopplacefigure
\definefloat[widefigure][figure][figure] \setupfloat [widefigure][location=flushleft] \setupcaptions[widefigure][width=\textwidth,align=middle]
\startplacewidefigure \framed[width=1.2\textwidth,framecolor=blue]{two} \stopplacewidefigure
\stoptext
Thanks, but this doesn't seem to be a solution to my problem, because the figures extend into the right margin always, and I want them to extend into the outer margin (i. e. left margin on left pages, right margin on right pages). I'm now using the following semi-automatic solution, but there is one problem left: The alignment is not applied to tikz pictures. Does somebody have an idea how to resolve this? Thank you and kind regards, Joshua \setuppagenumbering[alternative=doublesided] \setuplayout[backspace=4cm,width=12cm] \definemeasure[Widetext][\textwidth+\rightmargindistance+\rightmarginwidth] \define\WideFloatCommand {\dowithnextbox {\signalrightpage \ifdim\nextboxwd>\textwidth \doifrightpageelse{\leftaligned{\flushnextbox}}{\rightaligned{\flushnextbox}}% \else \midaligned{\flushnextbox}% \fi} \hbox} \definefloat [widefigure] [figure] [figure] \setupfloat [widefigure] [command=\WideFloatCommand] \usemodule[tikz] \showframe \starttext x \page \startplacewidefigure \framed[width=\measure{Widetext}]{One} \stopplacewidefigure \startplacewidefigure \framed[width=3cm]{Two} \stopplacewidefigure \startplacewidefigure \starttikzpicture \node [draw, minimum width=\measure{Widetext}] {Three}; \stoptikzpicture \stopplacewidefigure \startplacewidefigure \starttikzpicture \node [draw, minimum width=3cm] {Four}; \stoptikzpicture \stopplacewidefigure \startplacewidefigure \rightaligned{% \starttikzpicture \node [draw, minimum width=\measure{Widetext}] {Five}; \stoptikzpicture} \stopplacewidefigure \startplacewidefigure \midaligned{% \starttikzpicture \node [draw, minimum width=3cm] {Six}; \stoptikzpicture} \stopplacewidefigure \stoptext
Am 27.07.2014 um 16:54 schrieb Joshua Krämer
On 2014-07-25, 16:18, Hans Hagen wrote:
\showframe
\starttext
\startplacefigure \framed[width=.8\textwidth,framecolor=red]{one} \stopplacefigure
\definefloat[widefigure][figure][figure] \setupfloat [widefigure][location=flushleft] \setupcaptions[widefigure][width=\textwidth,align=middle]
\startplacewidefigure \framed[width=1.2\textwidth,framecolor=blue]{two} \stopplacewidefigure
\stoptext
Thanks, but this doesn't seem to be a solution to my problem, because the figures extend into the right margin always, and I want them to extend into the outer margin (i. e. left margin on left pages, right margin on right pages).
\setupfloat[widefigure][location=inner] Wolfgang
On 2014-07-27, 16:57, Wolfgang Schuster wrote:
Am 27.07.2014 um 16:54 schrieb Joshua Krämer
Thanks, but this doesn't seem to be a solution to my problem, because the figures extend into the right margin always, and I want them to extend into the outer margin (i. e. left margin on left pages, right margin on right pages).
\setupfloat[widefigure][location=inner]
Thank you. But this solution has the problem, too, that the alignment is ignored for tikz pictures (see example below). Kind regards, Joshua \setuppagenumbering[alternative=doublesided] \definefloat [widefigure] [figure] [figure] \setupfloat [widefigure] [location=inner] \usemodule[tikz] \showframe \starttext x \page \startplacewidefigure \framed[width=1.2\textwidth]{One} \stopplacewidefigure \startplacewidefigure \framed[width=3cm]{Two} \stopplacewidefigure \startplacewidefigure \starttikzpicture \node [draw, minimum width=1.2\textwidth] {Three}; \stoptikzpicture \stopplacewidefigure \startplacewidefigure \starttikzpicture \node [draw, minimum width=3cm] {Four}; \stoptikzpicture \stopplacewidefigure \startplacewidefigure \rightaligned{% \starttikzpicture \node [draw, minimum width=1.2\textwidth] {Five}; \stoptikzpicture} \stopplacewidefigure \startplacewidefigure \midaligned{% \starttikzpicture \node [draw, minimum width=3cm] {Six}; \stoptikzpicture} \stopplacewidefigure \stoptext
On Sun, 27 Jul 2014, Joshua Krämer wrote:
On 2014-07-27, 16:57, Wolfgang Schuster wrote:
Am 27.07.2014 um 16:54 schrieb Joshua Krämer
Thanks, but this doesn't seem to be a solution to my problem, because the figures extend into the right margin always, and I want them to extend into the outer margin (i. e. left margin on left pages, right margin on right pages).
\setupfloat[widefigure][location=inner]
Thank you. But this solution has the problem, too, that the alignment is ignored for tikz pictures (see example below).
This is a known issue. Wrap your tikz pictures inside a \hbox: \hbox{\starttikzpicture ... \stoptikzpicture} Aditya
On 2014-07-27, 14:13, Aditya Mahajan wrote:
On Sun, 27 Jul 2014, Joshua Krämer wrote:
Thank you. But this solution has the problem, too, that the alignment is ignored for tikz pictures (see example below). This is a known issue. Wrap your tikz pictures inside a \hbox: \hbox{\starttikzpicture ... \stoptikzpicture}
Great, thank you! Kind regards, Joshua
Thank you, Wolfang, it works great. There's only one problem: I also have even bigger floats which I need to turn. For these turned floats, the left/right alignment leads to undesired shifting, see the attached example. How can I avoid the shifting for those? I've tried to set command={} manually, but it doesn't work. May it be even possible to let Context automatically determine if the float is to be turned right or left, depending on its page? By the way, is \definemeasure meant as a replacement for \newdimen and \dimexpr? Are there caveats about switching to it? Thanks and kind regards, Joshua Krämer \setuppagenumbering[alternative=doublesided] \setuplayout[backspace=4cm,width=12cm] \definemeasure[Widetext][\textwidth+\rightmargindistance+\rightmarginwidth] \setupfloats[command=\FloatCommand] \define\FloatCommand {\dowithnextbox {\signalrightpage \ifdim\nextboxwd>\textwidth \doifrightpageelse{\leftaligned{\flushnextbox}}{\rightaligned{\flushnextbox}}% \else \midaligned{\flushnextbox}% \fi} \hbox} \showframe \starttext \startplacefigure[location={270, page}] \framed[width=\textheight,framecolor=red]{Turned} \stopplacefigure \startplacefigure \framed[width=\measure{Widetext},framecolor=red]{Left margin} \stopplacefigure \input knuth \page \startplacefigure \framed[width=\measure{Widetext},framecolor=red]{Right margin} \stopplacefigure \stoptext
participants (6)
-
Aditya Mahajan
-
Hans Hagen
-
Joshua Krämer
-
Keith J. Schultz
-
Rik Kabel
-
Wolfgang Schuster