Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

\newcommand{\dd}{\,\mathrm{d}}

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}.

Update

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.

share|improve this question
add comment

migrated from stackoverflow.com Oct 16 '12 at 6:56

This question came from our site for professional and enthusiast programmers.

1 Answer

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.

share|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
    
yes, I added some above. thank you again. –  Zoe Rowa Aug 6 '12 at 9:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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