php1ic wrote:Hi Sleort,
This may not be exactly what you want, but can edit it.
Code: Select all
\documentclass[a4paper,11pt]{article}
\newcommand{\myint}[2]{$\int \; #1 \, \mathrm{d}#2\,$}
\begin{document}
\myint{f(x)}{x}
\end{document}
There is a good explanation here
http://en.wikibooks.org/wiki/LaTeX/Customizing_LaTeX
Thanks for the reply! I am aware of that possibility, but no, that wasn't what I wanted. First of all this macro/newcommand does not open up for the other way (the "\int dx f(x)" way --where the differential is
before the integrand) of writing the integrals. Then I could of course define another macro (e.g. "\myint2") where this is the case, like
Code: Select all
\newcommand{\myint2}[2]{\int \mathrm{d}#2 \, #1 \,}
, but I don't think that is a very elegant (or smart) solution. And what if I would like to write a multidimensional integral? Or include explicit limits of integration? No, this simple \newcommand way of doing it isn't, unfortunately, good enough.
As I said: I think one has to focus on the differential d (the differential operator) and somehow make it dependent on the neighbor character. I don't know if it is possible, but the (pseudo)code should be something like:
if(character (excluding _{} and ^{}) to the right = integral) then (\! \mathrm{d}{#1} \,)
else if(character to the right = differential) then (\mathrm{d}{#1} \,)
else (\, \mathrm{d}{#1} \,)
Is this possible in Latex? (Or Tex...) If yes: how do I do it?