* framed algorithm / float: problems with line break
@ 2012-12-17 12:14 Andreas Mang
2012-12-18 10:17 ` Wolfgang Schuster
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Mang @ 2012-12-17 12:14 UTC (permalink / raw)
To: mailing list for ConTeXt users
Dear all,
Quick access: there is no line break in case algorithmic is used together with framed as a float.
I'd like to put some pseudocode in my document. I've used the algorithmic module. Since I'd like to refer to the algorithm in the text, I've defined a float environment. However, putting the pseudocode into my document, I've realised that it does not really stand out from the text. My first idea was to put some box around it. In the garden I've found some example for using framed together with floats:
http://wiki.contextgarden.net/Framed
However, this screws up the line break in the algorithmic environment. I could define manually the size of the box, but I think there might be better solutions. Any ideas or better ways for achieving this or a similar behaviour?!
Thanks in advance.
Cheers,
Andreas
ConTeXt ver: 2012.12.10 23:20 MKIV fmt: 2012.12.14
%%% MINIMAL EXAMPLE %%%
\usemodule[algorithmic]
\definefloat[algorithm][algorithms]
\setuplabeltext[de][algorithm=Algorithmus ]
\setupcaption[algorithm][
headstyle=bold,
location=top,
width=0.95\textwidth]
\starttext
\placealgorithm[top][alg:some-algorithm]{Some description of some algorithm.}{
\framed
[background=color,backgroundcolor=darkblue,
foreground=color,foregroundcolor=white,width=broad]{
\startalgorithmic
\STATE choose $\alpha\in(0,1)$
\WHILE{$\alpha < 100$}
\STATE $\alpha \leftarrow \alpha + \alpha$
\ENDWHILE
\stopalgorithmic
}
}
\stoptext
%%% MINIMAL EXAMPLE %%%
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: framed algorithm / float: problems with line break
2012-12-17 12:14 framed algorithm / float: problems with line break Andreas Mang
@ 2012-12-18 10:17 ` Wolfgang Schuster
2012-12-18 10:41 ` Andreas Mang
0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Schuster @ 2012-12-18 10:17 UTC (permalink / raw)
To: mailing list for ConTeXt users
Am 17.12.2012 um 13:14 schrieb Andreas Mang <mang@imt.uni-luebeck.de>:
> Dear all,
>
> Quick access: there is no line break in case algorithmic is used together with framed as a float.
>
> I'd like to put some pseudocode in my document. I've used the algorithmic module. Since I'd like to refer to the algorithm in the text, I've defined a float environment. However, putting the pseudocode into my document, I've realised that it does not really stand out from the text. My first idea was to put some box around it. In the garden I've found some example for using framed together with floats:
>
> http://wiki.contextgarden.net/Framed
>
> However, this screws up the line break in the algorithmic environment. I could define manually the size of the box, but I think there might be better solutions. Any ideas or better ways for achieving this or a similar behaviour?!
>
> Thanks in advance.
>
> Cheers,
> Andreas
>
> ConTeXt ver: 2012.12.10 23:20 MKIV fmt: 2012.12.14
>
> %%% MINIMAL EXAMPLE %%%
> \usemodule[algorithmic]
>
>
> \definefloat[algorithm][algorithms]
>
> \setuplabeltext[de][algorithm=Algorithmus ]
>
> \setupcaption[algorithm][
> headstyle=bold,
> location=top,
> width=0.95\textwidth]
>
>
> \starttext
>
> \placealgorithm[top][alg:some-algorithm]{Some description of some algorithm.}{
> \framed
> [background=color,backgroundcolor=darkblue,
> foreground=color,foregroundcolor=white,width=broad]{
You have to add “align=right” to \framed to force a multiline frame but you don’t need
the command because floats do also use the \framed command. You can use this feature
and set the background with \setupfloat, only the text color can’t be set with \setupfloat
because it’s applied to late in the process and a manual setting is necessary.
I can add a “color” key to the algorithmic environment which allows you to set the color
with \setupalgorithmic and you don’t need the \white command after \startalgorithmic
anymore.
\usemodule[algorithmic]
\definefloat[algorithm][algorithms]
\setuplabeltext[de][algorithm=Algorithmus ]
\setupcaption
[algorithm]
[headstyle=bold,
location=top,
width=0.95\textwidth]
\setupfloat
[algorithm]
[background=color,
backgroundcolor=darkblue]
\starttext
\placealgorithm[top][alg:some-algorithm]{Some description of some algorithm.}
{\startalgorithmic\white
\STATE choose $\alpha\in(0,1)$
\WHILE{$\alpha < 100$}
\STATE $\alpha \leftarrow \alpha + \alpha$
\ENDWHILE
\stopalgorithmic}
\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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-12-18 10:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-17 12:14 framed algorithm / float: problems with line break Andreas Mang
2012-12-18 10:17 ` Wolfgang Schuster
2012-12-18 10:41 ` Andreas Mang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).