* Custom latex environments using properties
@ 2011-08-29 22:52 suvayu ali
2011-08-30 6:05 ` Jambunathan K
0 siblings, 1 reply; 6+ messages in thread
From: suvayu ali @ 2011-08-29 22:52 UTC (permalink / raw)
To: org-mode mailing list
Hi everyone,
I am trying to implement a way to wrap a custom latex environment
around a sub-tree where I specify the environment and its options as a
PROPERTY. I am expecting it to work as BEAMER_env or BEAMER_envargs
works for org-beamer export.
To give you an example:
* Bs decay (Bs->Dsh)
Bs->DsK or Dsπ
** Decay model
:PROPERTIES:
:LATEX_env: todonotes
:LATEX_envargs: green
:END:
1. Justify neglecting CP violation
2. Verify master equations
** Detector effects
:PROPERTIES:
:LATEX_env: todonotes
:LATEX_envargs: blue
:END:
1. How is the Gaussian used for smearing of proper time resolution
derived?
2. Why is the per event proper time error PDF needed? Why is smearing
of time resolution not enough?
I am hoping to get blocks with colour codes (using the todonotes
package) based on the org properties. I tried using the preprocess hook
to convert the org source to latex using the defined properties but the
conversion to latex escapes everything and the process to pdf part
breaks. I used the following code to modify the preprocess hook.
#+begin_src emacs-lisp
(defun my-org-export-latex-wrap-env ()
"Wrap heading with arbitrary latex environment."
(interactive)
(setq env (org-entry-get (point) "LATEX_env"))
(setq envargs (org-entry-get (point) "LATEX_envargs"))
(let ((heading (org-get-heading t))
(text (org-get-entry)))
(org-mark-subtree)
(delete-region (region-beginning) (region-end))
(insert (concat env "[inline, color=" envargs "]{%\n"
"\\textbf{" heading "}\\protect\\linebreak{}%\n"
text "\n}%\n"))))
;; the following snippet is from my hook
(dolist (match spltags)
(org-map-entries (lambda () (my-org-export-latex-wrap-env))
match))
#+end_src
Any one has ideas about what else I can try?
--
Suvayu
Open source is the future. It sets us free.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Custom latex environments using properties
2011-08-29 22:52 Custom latex environments using properties suvayu ali
@ 2011-08-30 6:05 ` Jambunathan K
2011-08-30 6:51 ` Sebastien Vauban
0 siblings, 1 reply; 6+ messages in thread
From: Jambunathan K @ 2011-08-30 6:05 UTC (permalink / raw)
To: suvayu ali; +Cc: org-mode mailing list
suvayu ali <fatkasuvayu+linux@gmail.com> writes:
Suvayu
> Hi everyone,
>
> I am trying to implement a way to wrap a custom latex environment
> around a sub-tree where I specify the environment and its options as a
> PROPERTY. I am expecting it to work as BEAMER_env or BEAMER_envargs
> works for org-beamer export.
Not strictly answering your question. But is tangentially related ...
The excerpt pasted below is from org-special-blocks.el. I am not much
familiar with LaTeX. I hope these special blocks could be used for
achieving the desired resutls.
Also there is a way to wrap a block of text in custom divs in case of
HTML exporter.
,----
| ;; This package generalizes the #+begin_foo and #+end_foo tokens.
|
| ;; To use, put the following in your init file:
| ;;
| ;; (require 'org-special-blocks)
|
| ;; The tokens #+begin_center, #+begin_verse, etc. existed previously.
| ;; This package generalizes them (at least for the LaTeX and html
| ;; exporters). When a #+begin_foo token is encountered by the LaTeX
| ;; exporter, it is expanded into \begin{foo}. The text inside the
| ;; environment is not protected, as text inside environments generally
| ;; is. When #+begin_foo is encountered by the html exporter, a div
| ;; with class foo is inserted into the HTML file. It is up to the
| ;; user to add this class to his or her stylesheet if this div is to
| ;; mean anything.
`----
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Custom latex environments using properties
2011-08-30 6:05 ` Jambunathan K
@ 2011-08-30 6:51 ` Sebastien Vauban
2011-08-30 7:21 ` Jambunathan K
0 siblings, 1 reply; 6+ messages in thread
From: Sebastien Vauban @ 2011-08-30 6:51 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Hi Jambunathan and Suvayu,
Jambunathan K wrote:
> suvayu ali <fatkasuvayu+linux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>> I am trying to implement a way to wrap a custom latex environment around a
>> sub-tree where I specify the environment and its options as a PROPERTY. I
>> am expecting it to work as BEAMER_env or BEAMER_envargs works for
>> org-beamer export.
I have no particular experience with using such at the subtree level.
> Not strictly answering your question. But is tangentially related ...
>
> The excerpt pasted below is from org-special-blocks.el. I am not much
> familiar with LaTeX. I hope these special blocks could be used for
> achieving the desired resutls.
>
> Also there is a way to wrap a block of text in custom divs in case of
> HTML exporter.
>
> ,----
> | ;; This package generalizes the #+begin_foo and #+end_foo tokens.
> |
> | ;; To use, put the following in your init file:
> | ;;
> | ;; (require 'org-special-blocks)
> |
> | ;; The tokens #+begin_center, #+begin_verse, etc. existed previously.
> | ;; This package generalizes them (at least for the LaTeX and html
> | ;; exporters). When a #+begin_foo token is encountered by the LaTeX
> | ;; exporter, it is expanded into \begin{foo}. The text inside the
> | ;; environment is not protected, as text inside environments generally
> | ;; is. When #+begin_foo is encountered by the html exporter, a div
> | ;; with class foo is inserted into the HTML file. It is up to the
> | ;; user to add this class to his or her stylesheet if this div is to
> | ;; mean anything.
> `----
The answer of Jambunathan makes much sense, for such cases:
#+BEGIN_shaded
This will get a color background.
#+END_shaded
or
#+BEGIN_mcchangemargin {-1cm}{0cm}
This paragraph must be moved regarding the normal margins.
#+END_mcchangemargin {-1cm}{0cm}
Note -- The above does not work yet correctly, though, because of the
parameters to be passed onto the LaTeX environment.
But, the problem asked by Suvayu is different because the "todo" here is a
macro, not an environment. Hence the expected output:
\todo[inline]{\textbf{\textsf{\textsc{TODO} Provide your last offer.}}\\ }
Except from working in such a fashion:
#+LaTeX: \todo{
... your Org text
is here
inside ...
#+LaTeX: }
I don't see (currently) any other way to achieve what you'd like to get.
Best regards,
Seb
--
Sebastien Vauban
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Custom latex environments using properties
2011-08-30 6:51 ` Sebastien Vauban
@ 2011-08-30 7:21 ` Jambunathan K
[not found] ` <CAMXnza2jN0A3a=uWRetZykQ_OtwjyR47VYC_s6tCcePUb3YHOg@mail.gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Jambunathan K @ 2011-08-30 7:21 UTC (permalink / raw)
To: Sebastien Vauban; +Cc: public-emacs-orgmode-mXXj517/zsQ
> But, the problem asked by Suvayu is different because the "todo" here is a
> macro, not an environment. Hence the expected output:
>
> \todo[inline]{\textbf{\textsf{\textsc{TODO} Provide your last offer.}}\\ }
>
> Except from working in such a fashion:
>
> #+LaTeX: \todo{
> ... your Org text
> is here
> inside ...
> #+LaTeX: }
>
> I don't see (currently) any other way to achieve what you'd like to
> get.
This use case suggests that a latex environment may not be always be
what the user wants and there could be cases where a macro might be the
most appropriate one.
I sure think the special block handler can be taught to surround the
special blocks with
\todo { } instead of \begin{todo} ... \end{todo}.
But the more general solution might be to have the user register
handlers (callbacks) for each of the special "named" blocks and have him
handle it from his end. This way he can sneak the custom arguments to
the macros (is that what you call it?) without mucking too much with
properties etc.
May be Suvayu can re-define the below hook and quickly prototype
something and record his experience in this thread..
--8<---------------cut here---------------start------------->8---
(defun org-special-blocks-convert-latex-special-cookies ()
"Converts the special cookies into LaTeX blocks."
(goto-char (point-min))
(while (re-search-forward "^ORG-\\([^ \t\n]*\\)[ \t]*\\(.*\\)-\\(START\\|END\\)$" nil t)
(replace-match
(if (equal (match-string 3) "START")
(concat "\\begin{" (match-string 1) "}" (match-string 2))
(concat "\\end{" (match-string 1) "}"))
t t)))
--8<---------------cut here---------------end--------------->8---
Jambunathnan K.
>
> Best regards,
> Seb
--
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-08-30 18:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-29 22:52 Custom latex environments using properties suvayu ali
2011-08-30 6:05 ` Jambunathan K
2011-08-30 6:51 ` Sebastien Vauban
2011-08-30 7:21 ` Jambunathan K
[not found] ` <CAMXnza2jN0A3a=uWRetZykQ_OtwjyR47VYC_s6tCcePUb3YHOg@mail.gmail.com>
2011-08-30 17:20 ` Jambunathan K
2011-08-30 18:07 ` Suvayu Ali
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.