0

I want to define an abbreviation, for example, \newcommand{\pca}{Principal Component Analysis}. It seems trivial, but I am unable to do it. Please see below the code snippet-

\documentclass{article}

% define an abbreviation
\newcommand{\pca}{Principal Component Analysis}

\begin{document}
\pca is an unsupervised, non-parametric statistical technique primarily in machine learning. The dimensionality reduction can be done using \pca.
\end{document}

Below is a screenshot of the generated output-

enter image description here

It can be seen that there is no space between "analysis" and "is" as highlighted in the screenshot above.

Adding a space intentionally using \pca~is could be a workaround, but I believe there must be a better way. Please suggest.

ravi
  • 1,618
  • you can use ~ or \ or {} to get the space. (~` prevents line breaking) – David Carlisle May 19 '20 at 13:21
  • @PhelypeOleinik: Thank you very much. \pca{} is working fine. But can't we omit parenthesis just like \alpha, \beta, \gamma, etc.? – ravi May 19 '20 at 13:21
  • it is the same with \alpha except that spaces are ignored in math, in math $a b$ is the same as $ab$ but in text you need the space. – David Carlisle May 19 '20 at 13:24
  • @DavidCarlisle: I understood. Thank you very much. The syntax \pca{} looks like passing no arguments to it, (although the command \pca is already defined to take no arguments). – ravi May 19 '20 at 13:26
  • no it's a group, like {\itshape this is italic} this not {} don't always mean arguments in tex – David Carlisle May 19 '20 at 13:29
  • I see. Thank you very much for explaining to me. – ravi May 19 '20 at 13:30

0 Answers0