From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: Re: Mathematical Pseudocode in Source Block Date: Thu, 12 Aug 2010 12:46:08 -0400 Message-ID: <87sk2jsrsf.fsf@stats.ox.ac.uk> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from [140.186.70.92] (port=44857 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OjavH-0007Xm-AT for emacs-orgmode@gnu.org; Thu, 12 Aug 2010 12:46:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OjavF-0000pV-TC for emacs-orgmode@gnu.org; Thu, 12 Aug 2010 12:46:31 -0400 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:41090) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OjavF-0000p4-Mc for emacs-orgmode@gnu.org; Thu, 12 Aug 2010 12:46:29 -0400 In-Reply-To: (Jeremiah Via's message of "Wed, 11 Aug 2010 12:47:28 -0700") 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: Jeremiah Via Cc: emacs-orgmode@gnu.org 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 > 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