Re: [O] [PATCH] Export: Override headline numbering via properties

2013-05-16 Thread Albert Z. Wang
Mark Edgington edgi...@gmail.com writes:

 Anyway, your patch will not work on back-ends that rely on Org to
 compute section numbers (e.g., ascii, html...) because even if you
 ignore numbering for a particular headline, it still adds up
 internally.  IOW, you also need to patch
 `org-export--collect-headline-numbering'.

 But that's not quite it, yet. Some back-ends (e.g., html) use that
 internal number as a unique identifier for the headline. Actually,
 the artificial restriction you are talking about is a way to
 allow every headline to be numbered in a unique way, even if that
 number doesn't appear in the output.

 I can see what you mean here -- but it doesn't exactly break
 anything -- it just makes the section-numbering within html, etc.
 documents to be non-consecutive *if these properties are used*.  If
 the main intent is to use these properties in conjunction with the
 LaTeX exporter, then this isn't a big problem (i.e. those who want
 to use them will just need to understand that they currently only
 work correctly with LaTeX, but that this will be fixed in the
 future).

 Since I wouldn't use this, I can hardly judge, but I would
 appreciate some feedback from other users before we go too far in
 the implementation.

 Agreed, but my (obviously biased) opinion is that it makes manual
 numbering-control more natural within org-mode, and something
 which doesn't require as much hacking with embedded LaTeX (or HTML,
 etc.)  code.

An alternative would be to stick this into ox-latex.el, which then
wouldn't interfere with other backends.

I also think this functionality is good to have, since longer latex
documents often have unnumbered sections (and there seem to be
periodic questions on various boards on how to achieve this).  While
one can mess around with the latex code, it's often a hassle when the
master document is in org and you need to recompile often.

For a recent project I needed a super-simple way to turn off numbering
(for intro and references), so based on the above I made the following
tiny modification to ox-latex.el, which looks up the LATEX_NUMBERED
property to decide whether to insert a numbered or unnumbered heading.
Since I didn't need it, inheritance isn't in here, but it should be
simple enough to add.

Since this wouldn't interfere with any other backends, perhaps there
will be fewer reservations about merging something like this into the
repo?

--
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 41cf1d0..33a39c7 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -1369,7 +1369,11 @@ holding contextual information.
   (unless (org-element-property :footnote-section-p headline)
 (let* ((class (plist-get info :latex-class))
   (level (org-export-get-relative-level headline info))
-  (numberedp (org-export-numbered-headline-p headline info))
+  (latex-numbered (org-export-get-node-property :LATEX_NUMBERED 
headline))
+  (numberedp
+   (cond ((equal latex-numbered n) nil)
+ ((equal latex-numbered y) t)
+ (t (org-export-numbered-headline-p headline info
   (class-sectionning (assoc class org-latex-classes))
   ;; Section formatting will set two placeholders: one for
   ;; the title and the other for the contents.
--




[O] fill paragraph: math and latex environments

2012-09-17 Thread Albert Z. Wang

Hello,

First off, thanks for this great piece of software!  It's made
document/markup management so much easier since I've discovered it.
I've just recently been having an issue I was wondering if anybody could
help with, namely, that fill-paragraph does not seem to work as
expected.

For display math equations delimited as
\[
a^2 + b^2 = c^2
\]
the equation gets folded inline -- seems to work fine with explicit
environments though ( \begin{equation*}...\end{equation*} ).  Has
anybody else experienced this?  Tweaking paragraph-start and
paragraph-separate do not seem to be doing the trick...

I just recently did a big update of the emacs system after a few months,
so it's possible there've been some relevant changes I'm unaware of, but
I wasn't able to find a solution by searching.

Thanks for any help!

--Albert







Re: [O] fill paragraph: math and latex environments

2012-09-17 Thread Albert Z. Wang
Nicolas Goaziou n.goaz...@gmail.com writes:

 Hello,

 a...@fastmail.fm (Albert Z. Wang) writes:

 I've just recently been having an issue I was wondering if anybody
 could help with, namely, that fill-paragraph does not seem to work as
 expected.

 For display math equations delimited as
 \[
 a^2 + b^2 = c^2
 \]
 the equation gets folded inline -- seems to work fine with explicit
 environments though ( \begin{equation*}...\end{equation*} ).  Has
 anybody else experienced this?  Tweaking paragraph-start and
 paragraph-separate do not seem to be doing the trick...

 Yes, \[...\] constructs are considered as inline objects (they belong to
 a paragraph, so they will be filled along with the paragraph). On the
 other hand, \begin{equation*} environments are full-fledged elements:
 they do not belong to a paragraph and are not filled.

Thanks for the clarification!  Is there an easy way to have them be
treated as full-fledged environments?  I usually prefer to use the above
for unnumbered display equations since it reduces visual clutter and
looks closer to the intent.

I've noticed that adding \\[ and \\] to
org-element-paragraph-separate will prevent complete inlining, but that
the newline after the mark will be removed, which makes the formatting a
little less clear.  Is it possible to treat \[ ... \] as full-fledged
unnumbered equation environments?  My own understanding of how the
parser works is insufficient to the task of changing its behavior
here...

It's not a very big deal, but if there's an easy way to accomplish this
I'd appreciate any help.  

Thanks,

--Albert




Re: [O] fill-paragraph: wrong behaviour after latex-environments

2012-05-03 Thread Albert Z. Wang
Benjamin Motz b.m...@uni-muenster.de writes:

 Hi,

 invoking fill-paragraph on the following org-code will delete the
 newline after \end{equation}:

 The relation
 \begin{equation}
 E=mc^2
 \end{equation}
 won't be further discussed here.

 This behaviour is undesirable because it makes the org-text less
 readable. Also, when adding '%' after \end{equation}, newline is still
 being deleted by fill-paragraph (and the text after '%' won't be
 exported e.g. by latex-export).

 Is there a workaround or can someone point me to the location where I
 can fix/change this behaviour?

 Thanks, Benjamin

I had the same issue; fixed it by adding the following org-mode-hook:

(add-hook 'org-mode-hook 
  (lambda ()
;; don't rewrap display equations into paragraphs
(setq paragraph-separate 
  (concat [\\f 
\\t]*\\(begin{\\|end{\\|\\[\\|\\]\\)\\|
  paragraph-separate))


This sets several new paragraph boundary markers to prevent wrapping
them into paragraphs: \begin{, \end{, and the unnumbered display
equation shortcut \[, \].





Re: [O] Orgmode markups inside LaTeX fragments

2012-03-13 Thread Albert Z. Wang

I had a similar issue with typesetting in theorem and proof
environments; what saved me from messy LaTeX syntax was
org-special-blocks.  More info is on Worg:

http://orgmode.org/worg/org-contrib/org-special-blocks.html

This is not *exactly* your situation, since this is using org syntax
within \begin{} ... \end{} blocks, but if you can adapt your commands
to be environments, this will get you what you want.

--
Albert Wang