Currently, I want to define a command that makes it easy for me to write the usual notation for a set in set theory. Using the \newcommand command, I was able to define the following:
\documentclass{article}
\usepackage{ifthen}
\usepackage{calc}
\usepackage{amsmath,amssymb,mathtools}
\usepackage{xcolor}
\newcommand{\TCConjunto}[2]{%
\ifthenelse{\equal{#1}{}\AND\equal{#2}{}}%
{\varnothing}%
{\ifthenelse{\equal{#1}{}}%
{{#2}}%
{\ifthenelse{\equal{#2}{}}%
{{#1}}%
{{#1,:,#2}}%
}%
}%
}%
%%-----
\newcommand{\TCUnion}[2]{%
\ifthenelse{\equal{#1}{}\AND\equal{#2}{}}%
{\varnothing}%
{\ifthenelse{\equal{#1}{}}%
{#2}%
{\ifthenelse{\equal{#2}{}}%
{#1}%
{#1\cup #2}%
}%
}%
}%
\begin{document}
\section{Introduction}
$\TCConjunto{}{}$
$\TCConjunto{A,B,C}{}$
$\TCConjunto{}{A,B,C}$
$\TCUnion{}{}$
$\TCUnion{A}{}$
$\TCUnion{}{B}$
$\TCUnion{A}{B}$
%%%%%%$\TCUnion{A}{\TCUnion{B}{C}}$
\end{document}
The commands I just mentioned work with "simple" parameters. In a line of code, I've used the % symbol to highlight a problem; when I try to nest one of those commands with itself it throws an error. Could you help me figure out the problem?


\cupand\varnothingnormally, without defining new commands? In addition to introducing potential errors you have to fix like the one here, I would imagine that defining commands with long names would cause clutter and affect how easy it is to read your own code. – gz839918 Jul 28 '23 at 02:28