You are not logged in.
I would like to make a command to write sets with constraints, so in my LaTeX I could write something like
\SetWithConstraint{x}{x^2 > 0}
Instead of having to manually do
\left{x | x^2 > 0 \right}
Here is the initial command definition I put in my preamble:
\newcommand{\SetWithContraint}[2]{\left\{#1\,|\,#2\right\}}
It seemed to work pretty well at first, for example this comes out looking pretty good:
However, I would like a way to have the size of the | in the middle match the size of the braces enclosing the set definition. My results here using that command look horrible:
Does anyone know a good way to accomplish this? I'd really prefer my TeX files weren't cluttered with garbage regarding explicit layouts of individual characters. Thanks!
Offline
You could cheat and use "\left|" to get a | that changes its length according to what it needs to be. You'd also need to match it with a null brace (?), by putting "\right." somewhere.
Why did the vector cross the road?
It wanted to be normal.
Offline
Thanks. I completely forgot about being able to use the "." character in \left, \right commands as you suggested. It still doesn't look great like that, but it does match what I was asking for.. lol
Now the bar definitely looks too tall though, since it matched the size of the outer brace. I guess I should have asked if it's possible to make it the next size down from the size of the brace. Does anyone have a better idea for how to do this that doesn't have the limitations this command does?
\newcommand{\SetWithContraint}[2]{\left\{#1\,\left|\,#2\right.\right\}}
Is there a way to do this that wouldn't be considered cheating? Sorry if it's a noob question whose correct answer is "RTFM", but I haven't seen a good example of how to do this cleanly yet. Thanks again for the help, mathstyperson!
Offline
math. Using \left to line up the | doesn't look right when the right side is small and the left side big
i.e., here's the code for the command:
\newcommand{\SetWithContraint}[2]{\left\{\,#1\ \left|\ #2\,\right.\right\}}
And if I use it like this:
\[
\Defined
{B_N}
{\SetWithContraint
{
\SetMember
{
\FiniteSum{a_i z^{n-i}}{i}{0}{n}
}
{
\Polynomials{\ComplexNumbers}{z}
}
}
{
FOO!
}
}
\]
I get
where \SetMember, \Defined, etc. are commands I made up to try to decouple the logic of the markup from the characters used to display it.
Offline
It's a good command to have, but with a pretty long name. Reminds me of Java. I would recommend:
SetC
Personally in commands, the more lowercase the better so I would actually make it
setc
It's all about reducing the number of keystrokes (whilst maintaining readability).
"In the real world, this would be a problem. But in mathematics, we can just define a place where this problem doesn't exist. So we'll go ahead and do that now..."
Offline
It's a good command to have, but with a pretty long name. Reminds me of Java. I would recommend:
SetC
Personally in commands, the more lowercase the better so I would actually make it
setc
It's all about reducing the number of keystrokes (whilst maintaining readability).
When I'm coding something in any language, I only like to use short variable names for names defined in small scopes. For something global that's going to be used a lot to express the semantics of my paper, I'd much rather be as explicit as possible in my naming. I feel like if I stop writing a document and then come back a year later to make corrections or changes, I'll understand \SetWithConstraint more quickly than I will \SetC (maybe I'd think \SetC was a command for the set of complex numbers, for instance). I use the camel-case with uppercase first letters to try to keep my defined names from conflicting with the symbols AMS defines.
Offline