Math & ScienceDefining math operators that accept input.

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
dtmurphree
Posts: 2
Joined: Thu Jan 05, 2012 8:27 pm

Defining math operators that accept input.

Post by dtmurphree »

I am writing a paper that requires arbitrary R-module homomorphism groups Hom_R(*,X) and Hom_R(X,*)to be typed frequently. I would like to declare math operators that take input so that I can type "\rHom{B}" and have the output "Hom_R(B,X)" and type "\lHom{A}" and have the output "Hom_R(X,A)". So far the best I can come up with still requires me to type out the _R(B,X) part.

Recommended reading 2024:

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

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

kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

Defining math operators that accept input.

Post by kaiserkarl13 »

dtmurphree wrote:I am writing a paper that requires arbitrary R-module homomorphism groups Hom_R(*,X) and Hom_R(X,*)to be typed frequently. I would like to declare math operators that take input so that I can type "\rHom{B}" and have the output "Hom_R(B,X)" and type "\lHom{A}" and have the output "Hom_R(X,A)". So far the best I can come up with still requires me to type out the _R(B,X) part.
I'm having to guess somewhat as to what you want the input commands to be, but how about this:

Code: Select all

\newcommand*{\rHom}[2]{\mathrm{Hom_R}(#1,#2)}
\newcommand*{\lHom}[2]{\mathrm{Hom_R}(#2,#1)}
Then you would type

Code: Select all

  \rHom{B}{X} \lHom{A}{X}
to get "Hom_R(B,X) Hom_R(X,A)"
dtmurphree
Posts: 2
Joined: Thu Jan 05, 2012 8:27 pm

Defining math operators that accept input.

Post by dtmurphree »

kaiserkarl13 wrote:
dtmurphree wrote:I am writing a paper that requires arbitrary R-module homomorphism groups Hom_R(*,X) and Hom_R(X,*)to be typed frequently. I would like to declare math operators that take input so that I can type "\rHom{B}" and have the output "Hom_R(B,X)" and type "\lHom{A}" and have the output "Hom_R(X,A)". So far the best I can come up with still requires me to type out the _R(B,X) part.
I'm having to guess somewhat as to what you want the input commands to be, but how about this:

Code: Select all

\newcommand*{\rHom}[2]{\mathrm{Hom_R}(#1,#2)}
\newcommand*{\lHom}[2]{\mathrm{Hom_R}(#2,#1)}
Then you would type

Code: Select all

  \rHom{B}{X} \lHom{A}{X}
to get "Hom_R(B,X) Hom_R(X,A)"

Thank you so much! This was almost exactly what I was looking for, and close enough for me to get what to do next. I kept trying to do it as a

Code: Select all

\DeclareMathOperator
instead of a whole new command!

Code: Select all

\newcommand*{\rHom}[1]{\mathrm{Hom_R}(#1,X)}
\newcommand*{\lHom}[1]{\mathrm{Hom_R}(X,#1)}
was just what the doctor ordered and saves quite a few key strokes per hour!
Post Reply