* 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
* Re: Custom latex environments using properties
[not found] ` <CAMXnza2jN0A3a=uWRetZykQ_OtwjyR47VYC_s6tCcePUb3YHOg@mail.gmail.com>
@ 2011-08-30 17:20 ` Jambunathan K
2011-08-30 18:07 ` Suvayu Ali
0 siblings, 1 reply; 6+ messages in thread
From: Jambunathan K @ 2011-08-30 17:20 UTC (permalink / raw)
To: suvayu ali; +Cc: Orgmode, Sebastien Vauban
[-- Attachment #1: Type: text/plain, Size: 677 bytes --]
> However the most severe limitation was the inability to search for an
> entry like this with a tags search or assign a TODO keyword or maybe
> even add a timestamp. I guess I could have a separate heading above a
> block like this for these features. I will try to fool around some
> more and see whether I get any other more complete solutions.
What you need is actually inline tasks. The attached file should give
you pointers on how to proceed ahead.
Feel free to modify `org-latex-format-inlinetask' as you wish.
Suggestion to maintainers: `org-inlinetask-export-templates' is too
"hairy" for a normal user. May be they should be more user-friendly.
Jambunathan K.
[-- Attachment #2: odt-export-bug.org --]
[-- Type: text/x-org, Size: 1792 bytes --]
#+TITLE: odt-export-bug.org
#+AUTHOR: Jambunathan K
#+EMAIL: kjambunathan@gmail.com
#+DATE: 2011-08-30 Tue
#+DESCRIPTION:
#+KEYWORDS:
#+LANGUAGE: en
#+OPTIONS: H:3 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
#+OPTIONS: TeX:t LaTeX:dvipng skip:nil d:nil todo:t pri:nil tags:not-in-toc
#+EXPORT_SELECT_TAGS: export
#+EXPORT_EXCLUDE_TAGS: noexport
#+LINK_UP:
#+LINK_HOME:
#+XSLT:
#+latex_header: \usepackage[text width=10cm]{todonotes}
* COMMENT Setup
#+begin_src emacs-lisp
(push '(latex "%s" '((org-latex-format-inlinetask heading content
todo priority tags)))
org-inlinetask-export-templates)
(defun org-latex-format-inlinetask (heading content todo priority tags)
(let ((color (cond
((string-match "Qn" tags)
"blue!40")
((string-match "Ans" tags)
"yellow!40")
(t
"red!40"))))
(concat
(format "\\todo[inline,color=%s]{" color)
(format "\\textbf{%s}" heading)
content "}")))
#+end_src
* B oscillations
B lifetime oscillations is a purely QM effect. It has the functional
form of an exponential decay function modulated by oscillatory phases
due to interference b/w heavy and light states (cos, sin, cosh and
sinh functions related to the mass and decay width differences (Δm and
ΔΓ) b/w the two eigenstates).
_Questions_:
*************** Inline Question :Qn:
1. How is the Gaussian used for smearing of proper
time resolution derived?
2. Why is the proper time error PDF needed? Why is
smearing of time resolution not enough?
*************** END
*************** Inline Answer :Ans:
This is seems to be a reasonable answer.
*************** END
*************** Untagged Inline task
blah blah
*************** END
[-- Attachment #3: odt-export-bug.pdf --]
[-- Type: application/pdf, Size: 48771 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Custom latex environments using properties
2011-08-30 17:20 ` Jambunathan K
@ 2011-08-30 18:07 ` Suvayu Ali
0 siblings, 0 replies; 6+ messages in thread
From: Suvayu Ali @ 2011-08-30 18:07 UTC (permalink / raw)
To: Jambunathan K; +Cc: Orgmode, Sebastien Vauban
Hi Jambu,
On Tue, 30 Aug 2011 22:50:07 +0530
Jambunathan K <kjambunathan@gmail.com> wrote:
>
> > However the most severe limitation was the inability to search for
> > an entry like this with a tags search or assign a TODO keyword or
> > maybe even add a timestamp. I guess I could have a separate heading
> > above a block like this for these features. I will try to fool
> > around some more and see whether I get any other more complete
> > solutions.
>
> What you need is actually inline tasks. The attached file should give
> you pointers on how to proceed ahead.
>
> Feel free to modify `org-latex-format-inlinetask' as you wish.
>
Actually that is how I started fiddling with the todonotes package. :)
The issue with inlinetasks is: it is a little inconvenient for
navigation compared to regular headlines and as you correctly mention
customising the export templates is a hair raising task. I never
managed to do it quite right. Thank you for your solution, I think this
will work fine for now. :)
> Suggestion to maintainers: `org-inlinetask-export-templates' is too
> "hairy" for a normal user. May be they should be more user-friendly.
>
> Jambunathan K.
>
--
Suvayu
Open source is the future. It sets us free.
^ 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 public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).