Could anyone tell me what is the command for this math symbol in LaTeX Math mode?
[Tex/LaTex] Latex Math Symbol
symbols
Related Solutions
Amongst other things (that most likely falls outside the scope of this question), #
is used to reference arguments. In a general setting,
\newcommand{<cmd>}[<n>][<opt>]{<stuff>}
allows you to reference any of the <n>
arguments inside <stuff>
using #1
(for the first argument, which is optional in this case), #2
(for the second argument), ... #n
(for the n-th argument) up to 9. There are ways to extend this, but it is highly discouraged from a user-experience point of view.
The above syntax also holds for \renewcommand
and \providecommand
(using LaTeX2e), and translates seamlessly to \newenvironment
and friends as well. There is also no distinction between the use of arguments as being optional or mandatory.
Here are some examples:
\documentclass{article}
\newcommand{\cmdA}[2]{Arg 1: #1; Arg 2: #2}% \cmdA{#1}{#2}
\newcommand{\cmdB}[2][abc]{Arg 1: #1; Arg 2: #2}% \cmdB[#1]{#2}
\newenvironment{envA}[2]
{EnvA -- Arg 1: #1; Arg 2: #2}% \begin{envA}{#1}{#2}
{}% \end{envA}
\newenvironment{envB}[2][xyz]
{EnvB -- Arg 1: #1; Arg 2: #2}% \begin{envB}[#1]{#2}
{}% \end{envB}
\begin{document}
\cmdA{123}{456}
\cmdA{}{789}
\cmdB[qwe]{rty}
\cmdB{klm}
\begin{envA}{foo}{bar}
stuff
\end{envA}
\begin{envB}[foo]{baz}
stuff
\end{envB}
\begin{envB}{barz}
stuff
\end{envB}
\end{document}
For the latter question, see What do \makeatletter
and \makeatother
do? - since @
is special. That is, since you're using @
somewhere inside your macro definitions (it's okay in the replacement text), then you need to be careful. To that end, wrap \makeatletter
...\makeatother
around it if not used inside a class or style file.
Specific to your example:
\newcommand{\mytitle}[2][]%
{\newcommand\@mytitle{#2}
\ifthenelse{\not\equal{#1}{}}
{\newcommand\@shortmytitle{#1\ \ldots}}
{\newcommand\@shortmytitle{\@mytitle}}
}
In the outer part you have
\newcommand{\mytitle}[2][]%
{%<stuff
}
This creates a macro \mytitle
that takes one optional argument (which is empty by default) and one mandatory argument. As such, it's called using \mytitle[<opt>]{<man>}
(where \mytitle{<man>}
is equivalent to \mytitle[]{<man>}
). In order to gain access to the arguments, you reference them as #1
for <opt>
and #2
for <man>
. If you have macros with arguments inside other macros, the argument references "double" at every level. For more on this, see What is the meaning of double pound symbol (##1
) in an argument?.
The use of @
in macros is not possible in general, since control sequences are only allowed to contain letters (as designated by their category codes), and @
is not a letter. So, in order to create a macro of the form \@mytitle
, you need to make sure @
is a letter first. Why would one want to go through the hassle if it requires additional care? Since it requires special care, there very little chance that other users may interfere with it, or even have packages clash with one another over the same macro names. For example, while \titlename
might be a very common choice for a title name holder macro, \title@n@me
might not be.
Well here is one that looks kinda like cheating, it uses amsmath
only, though adding calc
will make the definition much simpler:
\documentclass{article}
\usepackage{amsmath}
\newlength{\crossl}
\settowidth{\crossl}{$\times$}
\newlength{\ceql}
\settowidth{\ceql}{$\times=$}
\addtolength{\ceql}{-\crossl}
\newcommand{\crosseq}{\mathrel{\makebox[\crossl][l]{$\times\hspace{-\ceql}=$}}}
\begin{document}
$f(x)\crosseq g(x)\crosseq h(x)$
\end{document}
Result:
One can also play around with the position and the symbols used:
\newcommand{\crosseq}{\mathrel{\makebox[7.7778pt][l]{$\neq$\hspace{-6.7778pt}\raisebox{-2.5pt}{$\backslash$}}}}
EDIT: Since this answer is chose I will add some more solution, this time using egreg's suggestion as poking around with boxes will likely create unexpected spacing issue:
\newcommand{\crosseq}{\mathrel{\ooalign{\hidewidth$/$\hidewidth\cr\ooalign{\hidewidth$\backslash$\hidewidth\cr$=$\cr}\cr}}}
or
\newcommand{\crosseq}{\mathrel{\ooalign{\hidewidth$/$\hidewidth\cr\ooalign{\hidewidth\raisebox{-2pt}{$\backslash$}\hidewidth\cr$=$\cr}\cr}}}
Result:
EDIT2: Add [l]
option to \makebox
in order to adjust alignment.
Best Answer
This combines two
\sqcup
s and uses\mathchoice
so that it sets in any mathstyle.