\Opt is a vector of 5 elements
but some of them can be left empty.
Based on this nice answer I learnt how to test if a parameter is empty or not.
But as you'll see in my MWE I struggle with spaces. I manually add an extra space in \Opt{EMTN }{SPX }{jun }{ATM }{C} but no doubt there is an automated answer to avoid double space when a parameter is empty and more harmoniously display the elements.
\documentclass{article}
\usepackage{xcolor}
\newcommand{\Opt}[5]{%
{\color{blue!80}%
\if\relax\detokenize{#1}\relax\else\texttt{#1}\fi
} %I get a legit double space here if no %
{\color{orange!80!black}
\if\relax\detokenize{#2}\relax\else\texttt{#2}\fi
\if\relax\detokenize{#3}\relax\else\texttt{#3}\fi
\if\relax\detokenize{#4}\relax\else\texttt{#4}\fi
\if\relax\detokenize{#5}\relax\else\texttt{#5}\fi
}
}
\begin{document}
\Opt{EMTN }{SPX }{}{}{C}
\Opt{EMTN }{SPX }{jun }{ATM }{C}
\Opt{EMTN}{SPX}{}{}{C}
\Opt{FUND}{AAPL}{jun}{OTM}{C}
\Opt{FUND }{AAPL }{jun }{OTM }{C}
\Opt{}{SPX }{}{}{Put}
\end{document}



{one after80}one after}one afterblack}and another after}the%after\fido nothing as white space after a command name is ignored, you need%on the other` lines to avoid adding space. – David Carlisle Mar 13 '21 at 01:22}at the end and an (ignored) space after{black}plusa space here} %that percent does nothing if you leave a space before it. If you comment out all the spaces you are adding and remove the spaces in the arguments you should get no space in the result, then add spaces after the\texttt{#2}as you know in that branch they are non empty – David Carlisle Mar 13 '21 at 01:48\newcommand{\Opt}[5]{{\color{blue!80}\if\relax\detokenize{#1}\relax\else\texttt{#1 }\fi }{\color{orange!80!black}\if\relax\detokenize{#2}\relax\else\texttt{#2 }\fi\if\relax\detokenize{#3}\relax\else\texttt{#3 }\fi\if\relax\detokenize{#4}\relax\else\texttt{#4 }\fi\if\relax\detokenize{#5}\relax\else\texttt{#5}\fi}}. The calls would be `\Opt{EMTN}{SPX}{}{}{C}\Opt{EMTN}{SPX}{jun}{ATM}{C}
\Opt{EMTN}{SPX}{}{}{C}
\Opt{FUND}{AAPL}{jun}{OTM}{C}
\Opt{FUND}{AAPL}{jun}{OTM}{C}
\Opt{}{SPX}{}{}{Put}`
– Steven B. Segletes Mar 13 '21 at 01:56