Using the package algorithm2e

231 views
Skip to first unread message

Christophe Bal

unread,
Sep 15, 2014, 4:01:14 PM9/15/14
to sage-...@googlegroups.com
Hello William.

I would like to use the package algorithm2e but the following testing code fails.

-----------------------------------------
%latex

\begin{algorithm}[H]
 \KwData{this text}
 \KwResult{write algorithm with \LaTeX2e}
 initialization\;
 \While{not at end of this document}{
  read current\;
  \eIf{understand}{
   go to next section\;
   current section becomes this one\;
   }{
   go back to the beginning of current section\;
  }
 }
 \caption{How to write algorithms}
\end{algorithm}
-----------------------------------------

Displaying algorithm is useful when teaching.

Best regards.
Christophe BAL

William A Stein

unread,
Sep 15, 2014, 4:39:10 PM9/15/14
to sage-cloud
On Mon, Sep 15, 2014 at 1:01 PM, Christophe Bal <proj...@gmail.com> wrote:
> Hello William.
>
> I would like to use the package algorithm2e but the following testing code
> fails.

Hi, Just type

latex.extra_preamble(r"\usepackage{algorithm2e}")

first, and you're good to go. In general, with %latex, you can do the
above to add all kinds of packages. Type latex.[tab] to see other
similar interesting things you can do, e.g., adding custom macros.

NOTE: I'm going to update SageMathCloud later today with some bugfixes
related to %auto, so that you can type

%auto
latex.extra_preamble(r"\usepackage{algorithm2e}")

in a cell, so that the above pre-amble gets set any time that
worksheet starts. The %auto functionality doesn't isn't 100% at the
moment.

>
> -----------------------------------------
> %latex
>
> \begin{algorithm}[H]
> \KwData{this text}
> \KwResult{write algorithm with \LaTeX2e}
> initialization\;
> \While{not at end of this document}{
> read current\;
> \eIf{understand}{
> go to next section\;
> current section becomes this one\;
> }{
> go back to the beginning of current section\;
> }
> }
> \caption{How to write algorithms}
> \end{algorithm}
>
> -----------------------------------------
>
> Displaying algorithm is useful when teaching.
>
> Best regards.
> Christophe BAL
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-cloud" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-cloud+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-cloud/CAAb4jGmF20Z2AfQ9GxPx27BqJrHoGgt15LVjbJwi5pD7t98Lnw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



--
William Stein
Professor of Mathematics
University of Washington
http://wstein.org
wst...@uw.edu

Christophe Bal

unread,
Sep 16, 2014, 4:30:21 AM9/16/14
to sage-...@googlegroups.com
Thanks for this.

I can't remember how to hide a Python code so as to only see the latex output. Can you refresh my memory ?

Christophe Bal

unread,
Sep 16, 2014, 5:03:46 AM9/16/14
to sage-...@googlegroups.com
I want to talk about the LaTeX code and not the Python one. Maybe a celle using %latex should be automatically hide like it is the case for %md.

Sorry for being an prototypical french who moans often. ;-)

William A Stein

unread,
Sep 16, 2014, 5:47:40 AM9/16/14
to sage-...@googlegroups.com
Put %hide at the top or just doubleclick on the output.
--
You received this message because you are subscribed to the Google Groups "sage-cloud" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-cloud+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-cloud/732c2d30-405c-43dd-93df-c60a59fe3570%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Christophe Bal

unread,
Sep 16, 2014, 5:57:28 AM9/16/14
to sage-...@googlegroups.com
So simple...

You received this message because you are subscribed to a topic in the Google Groups "sage-cloud" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sage-cloud/Z7wpKxC2Drw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sage-cloud+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-cloud/CALVmk4Gw99U_w_t%2Bn8UO_RmK8jDndjtGdgjh9pBfCcQcoY%3DYTA%40mail.gmail.com.

Christophe Bal

unread,
Sep 16, 2014, 6:03:29 AM9/16/14
to sage-...@googlegroups.com
I forgot to say thanks. ;-)
So simple...

To unsubscribe from this group and stop receiving emails from it, send an email to sage-cloud+unsubscribe@googlegroups.com.


--
William Stein
Professor of Mathematics
University of Washington
http://wstein.org
wst...@uw.edu

--
You received this message because you are subscribed to a topic in the Google Groups "sage-cloud" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sage-cloud/Z7wpKxC2Drw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sage-cloud+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages