emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Mathematical Pseudocode in Source Block
@ 2010-08-11 19:47 Jeremiah Via
  2010-08-12 16:30 ` Bastien
  2010-08-12 16:46 ` Dan Davison
  0 siblings, 2 replies; 4+ messages in thread
From: Jeremiah Via @ 2010-08-11 19:47 UTC (permalink / raw)
  To: emacs-orgmode

Hi there,

I was wondering if there was any way to make the source blocks work
with LaTeX formulas. I wanted to use it for some pesudocode; for
example:

while not converged
  for each state i
       \( U^{'}_i = r_i + \underset{a}{argmax} \sum{Pa_{ij}U_j} \)
       \( U_i \rightarrow U^{'}_i \)
  end for
end while

If a source block isn't possible, is there at least a way to get a
textbox around it?

Thank you
-- 
Jeremiah M. Via
School of Computer Science
University of Birmingham

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Mathematical Pseudocode in Source Block
  2010-08-11 19:47 Mathematical Pseudocode in Source Block Jeremiah Via
@ 2010-08-12 16:30 ` Bastien
  2010-08-12 16:46 ` Dan Davison
  1 sibling, 0 replies; 4+ messages in thread
From: Bastien @ 2010-08-12 16:30 UTC (permalink / raw)
  To: Jeremiah Via; +Cc: emacs-orgmode

Jeremiah Via <jxv911@cs.bham.ac.uk> writes:

> I was wondering if there was any way to make the source blocks work
> with LaTeX formulas. I wanted to use it for some pesudocode; for
> example:
>
> while not converged
>   for each state i
>        \( U^{'}_i = r_i + \underset{a}{argmax} \sum{Pa_{ij}U_j} \)
>        \( U_i \rightarrow U^{'}_i \)
>   end for
> end while
>
> If a source block isn't possible, is there at least a way to get a
> textbox around it?

Can you rephrase your question a bit?  I'm not sure to understand.  

Do you want to have a source block in an org file with mixed languages
and export this source block so that it is properly fontified in HTML?

-- 
 Bastien

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Mathematical Pseudocode in Source Block
  2010-08-11 19:47 Mathematical Pseudocode in Source Block Jeremiah Via
  2010-08-12 16:30 ` Bastien
@ 2010-08-12 16:46 ` Dan Davison
  2010-08-12 22:14   ` Jeremiah Via
  1 sibling, 1 reply; 4+ messages in thread
From: Dan Davison @ 2010-08-12 16:46 UTC (permalink / raw)
  To: Jeremiah Via; +Cc: emacs-orgmode

Jeremiah Via <jxv911@cs.bham.ac.uk> writes:

> Hi there,
>
> I was wondering if there was any way to make the source blocks work
> with LaTeX formulas. I wanted to use it for some pesudocode; for
> example:
>
> while not converged
>   for each state i
>        \( U^{'}_i = r_i + \underset{a}{argmax} \sum{Pa_{ij}U_j} \)
>        \( U_i \rightarrow U^{'}_i \)
>   end for
> end while
>
> If a source block isn't possible, is there at least a way to get a
> textbox around it?

Hi Jeremiah,

Absolutely. Here are some quick notes

- Org can recognise simple LaTeX constructs inline, without any special
  markup

  section 11.7 of the manual
  http://orgmode.org/org.html#Embedded-LaTeX

- The basic way to place more complex fragments of latex in an Org
  document is in a #+begin_latex block

  section 12.6 of the manual
  http://orgmode.org/org.html#LaTeX-and-PDF-export

- Personally I use the listings package to format pseudocode, e.g.

#+begin_latex
\begin{algorithm}
  \caption{An algorithm}
  \label{alg:myalg}
  \begin{lstlisting}[mathescape,escapeinside='']
    '\foreach individual $i$'
        '\foreach group $k$'
            $\gamma_{ik} \getsp Q_{k}\prod_{l}\prod_{a=1}^{2}P_{lkX_{ila}}$
  \end{lstlisting}
\end{algorithm}
#+end_latex

- Don't forget the nice Org functionality like C-c ' to view the latex
  code in a latex-mode buffer (manual section 11.3), and C-c C-x C-l to view a png image of
  the latex fragment (manual section 11.7.4).

- The latex can also be included in HTML export. By default this uses
  png images, but check out this thread for using MathJax and jsMath to
  have javascript-mediated rendering of LaTeX formulas in HTML with
  genuine fonts

http://thread.gmane.org/gmane.emacs.orgmode/28259

- You can use a #+latex_header line to specify additional latex
  preamble lines. E.g. I defined the \foreach command in a file
  emvbpl.sty and make sure that file is included with

#+latex_header: \usepackage{emvbpl}

- In addition, latex can be included inside begin_src latex blocks, to
  achieve a variety of extra functionality, and also some of the same
  functionality as above.

  chapter 14
  http://orgmode.org/org.html#Working-With-Source-Code


Don't hesitate to come back to this list with further questions.

Dan



>
> Thank you

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Mathematical Pseudocode in Source Block
  2010-08-12 16:46 ` Dan Davison
@ 2010-08-12 22:14   ` Jeremiah Via
  0 siblings, 0 replies; 4+ messages in thread
From: Jeremiah Via @ 2010-08-12 22:14 UTC (permalink / raw)
  To: Dan Davison; +Cc: emacs-orgmode

This is exactly what I needed.

Thanks for all your help!

On Thu, Aug 12, 2010 at 9:46 AM, Dan Davison <davison@stats.ox.ac.uk> wrote:
> Jeremiah Via <jxv911@cs.bham.ac.uk> writes:
>
>> Hi there,
>>
>> I was wondering if there was any way to make the source blocks work
>> with LaTeX formulas. I wanted to use it for some pesudocode; for
>> example:
>>
>> while not converged
>>   for each state i
>>        \( U^{'}_i = r_i + \underset{a}{argmax} \sum{Pa_{ij}U_j} \)
>>        \( U_i \rightarrow U^{'}_i \)
>>   end for
>> end while
>>
>> If a source block isn't possible, is there at least a way to get a
>> textbox around it?
>
> Hi Jeremiah,
>
> Absolutely. Here are some quick notes
>
> - Org can recognise simple LaTeX constructs inline, without any special
>  markup
>
>  section 11.7 of the manual
>  http://orgmode.org/org.html#Embedded-LaTeX
>
> - The basic way to place more complex fragments of latex in an Org
>  document is in a #+begin_latex block
>
>  section 12.6 of the manual
>  http://orgmode.org/org.html#LaTeX-and-PDF-export
>
> - Personally I use the listings package to format pseudocode, e.g.
>
> #+begin_latex
> \begin{algorithm}
>  \caption{An algorithm}
>  \label{alg:myalg}
>  \begin{lstlisting}[mathescape,escapeinside='']
>    '\foreach individual $i$'
>        '\foreach group $k$'
>            $\gamma_{ik} \getsp Q_{k}\prod_{l}\prod_{a=1}^{2}P_{lkX_{ila}}$
>  \end{lstlisting}
> \end{algorithm}
> #+end_latex
>
> - Don't forget the nice Org functionality like C-c ' to view the latex
>  code in a latex-mode buffer (manual section 11.3), and C-c C-x C-l to view a png image of
>  the latex fragment (manual section 11.7.4).
>
> - The latex can also be included in HTML export. By default this uses
>  png images, but check out this thread for using MathJax and jsMath to
>  have javascript-mediated rendering of LaTeX formulas in HTML with
>  genuine fonts
>
> http://thread.gmane.org/gmane.emacs.orgmode/28259
>
> - You can use a #+latex_header line to specify additional latex
>  preamble lines. E.g. I defined the \foreach command in a file
>  emvbpl.sty and make sure that file is included with
>
> #+latex_header: \usepackage{emvbpl}
>
> - In addition, latex can be included inside begin_src latex blocks, to
>  achieve a variety of extra functionality, and also some of the same
>  functionality as above.
>
>  chapter 14
>  http://orgmode.org/org.html#Working-With-Source-Code
>
>
> Don't hesitate to come back to this list with further questions.
>
> Dan
>
>
>
>>
>> Thank you
>



-- 
Jeremiah M. Via
School of Computer Science
University of Birmingham

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-08-12 22:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-11 19:47 Mathematical Pseudocode in Source Block Jeremiah Via
2010-08-12 16:30 ` Bastien
2010-08-12 16:46 ` Dan Davison
2010-08-12 22:14   ` Jeremiah Via

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).