Math & ScienceCommand for Subsets

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
holysword
Posts: 3
Joined: Mon Jul 19, 2010 9:08 pm

Command for Subsets

Post by holysword »

Hi everybody (I'm new here ^ ^)

So, I'm working with latex for years. I have my own .sty file, and I am trying to make it "clean" and easier to use - even for myself.

One thing that annoys me is when I have to write a subset, for instance

Code: Select all

$$\mathbb C^{x\times y\times z}$$
Recently I found out that I could do something like this:

Code: Select all

\makeatletter
\newcommand{\setf}[1]{%
  \@ifnextchar({\setf@i{#1}}{\setf@i{#1}({},{},{})}%
}

\def\setf@i#1(#2,#3,#4){%
  \ensuremath{\mathbb #1^{#2\times #3\times #4}
   } 
}
\makeatother
and then invoke only "\setf(x,y,z) C". However, I also use 2dimension and 1dimensional cases, and I don't want to have 3 different commands for doing that.

There is any way to define the "\setf" command such that it accepts (x,y,z) but also (x,y) and perhaps (x)?

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

Command for Subsets

Post by localghost »

TeX Frequently Asked Questions - More than one optional argument


Best regards and welcome to the board
Thorsten
holysword
Posts: 3
Joined: Mon Jul 19, 2010 9:08 pm

Re: Command for Subsets

Post by holysword »

In fact I know how to put more than one optional argument. This was not my question, but thank you for your attention.
Post Reply