emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] How to get numbered lists (1), (2), … ?


From: Nick Dokos
Subject: Re: [O] How to get numbered lists (1), (2), … ?
Date: Thu, 13 Oct 2011 15:10:18 -0400

[ I started this earlier but I guess I didn't send it out. Suvayu has
  replied in the meantime with a pointer to a better solution than this
  one, but this might be of some minor interest to some people as well -
  besides, I spent a whole 20 minutes on it, half of it trying to figure
  out why my mail was not working :-( : why let that effort go to
  waste?:-) ]


Marius Hofert <address@hidden> wrote:

> Dear Suvayu,
> 
> thanks. 
> It would be good to know how latex export can be customized to achieve this.
> 

Depends on how much customization you are willing to go through: there is an
enumerate.sty package in LaTeX that can do that:

--8<---------------cut here---------------start------------->8---
...
\usepackage{enumerate}
...
\begin{enumerate}[(1)]
\item foo
\item bar
\end{enumerate}
...
--8<---------------cut here---------------start------------->8---

Inserting the \usepackage from the org file is no problem:

--8<---------------cut here---------------end--------------->8---
#+LATEX_HEADER: \usepackage{enumerate}
...
--8<---------------cut here---------------end--------------->8---


Getting the argument to the enumerate environment in the right place is
another matter. I think the only way is to redefine org-list-generic-to-latex
like this (add this to your initialization file, .emacs or whatever, after you
load org):

--8<---------------cut here---------------start------------->8---
(require 'org-list)

(defun org-list-to-latex (list &optional params)
  "Convert LIST into a LaTeX list.
LIST is as returned by `org-list-parse-list'.  PARAMS is a property list
with overruling parameters for `org-list-to-generic'."
  (org-list-to-generic
   list
   (org-combine-plists
    '(:splice nil :ostart "\\begin{enumerate}[(1)]\n" :oend "\\end{enumerate}"
               :ustart "\\begin{itemize}\n" :uend "\\end{itemize}"
               :dstart "\\begin{description}\n" :dend "\\end{description}"
               :dtstart "[" :dtend "] "
               :istart "\\item " :iend "\n"
               :icount (let ((enum (nth depth '("i" "ii" "iii" "iv"))))
                         (if enum
                             ;; LaTeX increments counter just before
                             ;; using it, so set it to the desired
                             ;; value, minus one.
                             (format "\\setcounter{enum%s}{%s}\n\\item "
                                     enum (1- counter))
                           "\\item "))
               :csep "\n"
               :cbon "\\texttt{[X]}" :cboff "\\texttt{[ ]}"
               :cbtrans "$\\boxminus$")
    params)))
--8<---------------cut here---------------end--------------->8---

The only change is the definition of :ostart. Not a very flexible method, 
but it will serve in a pinch. ngz et al. might have better ideas.

I should say that there are other ways to customize enumeration labels
in LaTeX - see e.g. http://www.tex.ac.uk/cgi-bin/texfaq2html?label=enumerate -
but afaict they would all require some rewiring of the above function, similar
to the above.

Nick

> Cheers,
> 
> Marius
> 
> On 2011-10-13, at 11:37 , suvayu ali wrote:
> 
> > On Thu, Oct 13, 2011 at 11:11 AM, Marius Hofert
> > <address@hidden> wrote:
> >> Dear all,
> >> 
> >> In the manual, I found that numbered lists can be created with 1), 2), ... 
> >> or 1., 2., ...
> >> How can I get numbered lists like this: (1), (2),...?
> >> I found org-list-demote-modify-bullet, but the help (and a google search) 
> >> did not help me in finding a solution to this.
> >> 
> > 
> > I don't think you can. But you can customise latex export (maybe even
> > html export, but I don't know) to show lists like that in the exported
> > file.
> > 
> > I hope this helps.
> > 
> >> Cheers,
> >> 
> >> Marius
> >> 
> > 
> > 
> > 
> > -- 
> > Suvayu
> > 
> > Open source is the future. It sets us free.
> 
> 
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]