In a general tex-file, one can easily define a new command, for my case, let me take this as an example:

To put this code in header


I can use the shorter command to make the longer command work; it's good to do this, I also can compile org-file into tex if this command is added in header. However the preview C-c-x-l fails to recognize \dd even if this new command have been defined in header.

I think we can add some code in org package to make this work, right? how can I do this? I want to make preview C-c-xl recognize \dd as \mathrm{d}.


Let me expound my question.

I hope we can amend or add some codes in ~/org path/lisp/org-latex.el to make preview recognize \dd as \,\matherm{d} in every org-file.

The way @pmr posed works in each org-file which added that code by hand. I expect we can make this as default and needn't to add such code every time.


You need to add your newcommands to the header

#+LaTeX_HEADER: \newcommand{\dd}{\,\mathrm{d}}

* TestOrg
  $\dd  d$

then they are considered by preview.

Let this be the place where I rant: Don't do it. This will cage your documents inside LaTeX and you will never get them out again without some significant effort. No matter how much people tell you to use newcommand to define your won aliases: don't touch it.

| improve this answer | |
  • wow~I am curious about that if you used such codes you posted above and what did emacs happen? – Zoe Rowa Aug 6 '12 at 8:26
  • I have tried your code, it is useful. Thanks. However my purpose is to amend some codes in org setting-up to make every org-file can do this automatically. Is there any idea ? – Zoe Rowa Aug 6 '12 at 8:34
  • 1
    @x7x7 Please state that in your question. To get a default configuration for every use include – pmr Aug 6 '12 at 8:53
  • What is the alternative to not using newcommand? Maybe defining macros to type things you always repeat? – Guilherme Salomé Apr 26 '18 at 2:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.