From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeremiah Via Subject: Re: Mathematical Pseudocode in Source Block Date: Thu, 12 Aug 2010 15:14:19 -0700 Message-ID: References: <87sk2jsrsf.fsf@stats.ox.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=35864 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ojg2Y-0001Nl-Dz for emacs-orgmode@gnu.org; Thu, 12 Aug 2010 18:14:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ojg2X-00037v-1F for emacs-orgmode@gnu.org; Thu, 12 Aug 2010 18:14:22 -0400 Received: from mail-yw0-f41.google.com ([209.85.213.41]:58096) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ojg2W-00037r-UC for emacs-orgmode@gnu.org; Thu, 12 Aug 2010 18:14:20 -0400 Received: by ywg8 with SMTP id 8so823776ywg.0 for ; Thu, 12 Aug 2010 15:14:20 -0700 (PDT) In-Reply-To: <87sk2jsrsf.fsf@stats.ox.ac.uk> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Dan Davison Cc: emacs-orgmode@gnu.org This is exactly what I needed. Thanks for all your help! On Thu, Aug 12, 2010 at 9:46 AM, Dan Davison wrote= : > Jeremiah Via 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 >> =A0 for each state i >> =A0 =A0 =A0 =A0\( U^{'}_i =3D r_i + \underset{a}{argmax} \sum{Pa_{ij}U_j= } \) >> =A0 =A0 =A0 =A0\( U_i \rightarrow U^{'}_i \) >> =A0 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 > =A0markup > > =A0section 11.7 of the manual > =A0http://orgmode.org/org.html#Embedded-LaTeX > > - The basic way to place more complex fragments of latex in an Org > =A0document is in a #+begin_latex block > > =A0section 12.6 of the manual > =A0http://orgmode.org/org.html#LaTeX-and-PDF-export > > - Personally I use the listings package to format pseudocode, e.g. > > #+begin_latex > \begin{algorithm} > =A0\caption{An algorithm} > =A0\label{alg:myalg} > =A0\begin{lstlisting}[mathescape,escapeinside=3D''] > =A0 =A0'\foreach individual $i$' > =A0 =A0 =A0 =A0'\foreach group $k$' > =A0 =A0 =A0 =A0 =A0 =A0$\gamma_{ik} \getsp Q_{k}\prod_{l}\prod_{a=3D1}^{2= }P_{lkX_{ila}}$ > =A0\end{lstlisting} > \end{algorithm} > #+end_latex > > - Don't forget the nice Org functionality like C-c ' to view the latex > =A0code in a latex-mode buffer (manual section 11.3), and C-c C-x C-l to = view a png image of > =A0the latex fragment (manual section 11.7.4). > > - The latex can also be included in HTML export. By default this uses > =A0png images, but check out this thread for using MathJax and jsMath to > =A0have javascript-mediated rendering of LaTeX formulas in HTML with > =A0genuine fonts > > http://thread.gmane.org/gmane.emacs.orgmode/28259 > > - You can use a #+latex_header line to specify additional latex > =A0preamble lines. E.g. I defined the \foreach command in a file > =A0emvbpl.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 > =A0achieve a variety of extra functionality, and also some of the same > =A0functionality as above. > > =A0chapter 14 > =A0http://orgmode.org/org.html#Working-With-Source-Code > > > Don't hesitate to come back to this list with further questions. > > Dan > > > >> >> Thank you > --=20 Jeremiah M. Via School of Computer Science University of Birmingham