Math & ScienceIntegral style limits on user-defined commands?

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
yakeyglee
Posts: 5
Joined: Fri Oct 07, 2011 11:35 pm

Integral style limits on user-defined commands?

Post by yakeyglee »

Hey guys,

I just recently defined the following command called \Cint which features an integral sign with a C overlayed (I want to convey a line integral over curve C).

Code: Select all

\newcommand{\Cint}{\mathrlap \int \hspace{1.1px} C \ }
Unfortunately, when I try to put limits on the integral, I find that it behaves just like a regular character, putting them in the standard superscript/subscript positions. For example:

Code: Select all

\Cint_{\vec r_i}^{\vec r_f}
Additionally, I'd like to be able to use the limits command just like you would be able to for a normal integral so that the bounds of integration appear directly above and below the integral sign. The following code outputs an error as the command is currently defined.

Code: Select all

\Cint\limits_{\vec r_i}^{\vec r_f}
What can I change in the definition of \Cint to give me the flexibility of adding limits in the standard way and having them displayed as desired?

--- Trevor
Last edited by yakeyglee on Mon Oct 31, 2011 6:33 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Integral style limits on user-defined commands?

Post by localghost »

I remember a slightly different notation for the line integral [1]. With your notation you could run into trouble when it comes to calculating the line integral for a closed curve.

However, the command definition is the important part here. That is to say the sequence of the stuff you put in. The \int command has to be the last one in order not to loose the properties for its limits. So, try the below example.

Code: Select all

\documentclass[11pt]{article}

\newcommand{\Cint}{C\kern-1em\int}

\begin{document}
  \[
    \Cint_a^b
  \]
\end{document}
And next time please prepare a proper minimal example. The \mathrlap command is not from vanilla LaTeX and nobody who doesn't know that it is provided by the mathtools package is willing to guess where it comes from.

[1] Line integral – Wikipedia, the free encyclopedia


Thorsten
Attachments
The rendered output of the given code example.
The rendered output of the given code example.
Cint.png (2.93 KiB) Viewed 3326 times
yakeyglee
Posts: 5
Joined: Fri Oct 07, 2011 11:35 pm

Integral style limits on user-defined commands?

Post by yakeyglee »

localghost wrote:I remember a slightly different notation for the line integral [1]. With your notation you could run into trouble when it comes to calculating the line integral for a closed curve.

However, the command definition is the important part here. That is to say the sequence of the stuff you put in. The \int command has to be the last one in order not to loose the properties for its limits. So, try the below example.

Code: Select all

\documentclass[11pt]{article}

\newcommand{\Cint}{C\kern-1em\int}

\begin{document}
  \[
    \Cint_a^b
  \]
\end{document}
And next time please prepare a proper minimal example. The \mathrlap command is not from vanilla LaTeX and nobody who doesn't know that it is provided by the mathtools package is willing to guess where it comes from.

[1] Line integral – Wikipedia, the free encyclopedia


Thorsten
For closed curve line integrals, I'd just use the typical notation.

Code: Select all

\oint_C
I made the new notation for the other so I could specify bounds without having the lower bound confused with the curve of integration.

Thanks for the help.
Post Reply