Am 17.12.2012 um 13:14 schrieb Andreas Mang
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