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.

Possible Duplicate:
What’s the proper way to typeset a differential operator?

\newcommand{d}[1]{\:\textrm{d}{#1}} 

That is my new comamnd for writing the dx of an intergral. Just wanted to be able to type this in my code.

\d{x}  <<<where the x is the variable of integration>>>

What did I do wrong?

share|improve this question
    
Related Question: Should I \mathrm the d in my integrals? –  Peter Grill Nov 17 '12 at 7:56
add comment

marked as duplicate by Claudio Fiandrino, Thorsten, Andrew Swann, Stephen, Martin Schröder Dec 18 '12 at 18:30

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

up vote 8 down vote accepted
\newcommand\d[1]{\:\textrm{d}#1} 
\renewcommand\d[1]{\:\textrm{d}#1} % if \d is already defined

only for a definition of an environment you use \newenvironment{env}. Another useful definition is:

\newcommand*\diff{\mathop{}\!\mathrm{d}}

in your definition you do not really need the argument and using \mathrm makes more sense, then it takes the d from the same math font and not from the text font

\documentclass{article}
\renewcommand\d[1]{\:\textrm{d}#1}
\newcommand*\diff{\mathop{}\!\mathrm{d}}
\begin{document}
$\d x \textrm{ or } \diff x  $
\end{document}
share|improve this answer
    
Ok. uh. so what do I type in the body? –  MaoYiyi Nov 17 '12 at 7:49
    
\d{x} or \d x or \diff x –  Herbert Nov 17 '12 at 7:52
1  
@MaoYiyi: You should not use \d as that is already used elsewhere. –  Peter Grill Nov 17 '12 at 7:53
    
@Herbert that didn't work. –  MaoYiyi Nov 17 '12 at 7:57
1  
@MaoYiyi: sure makes no difference –  Herbert Nov 17 '12 at 8:17
show 5 more comments

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