0

I would like to define a command that does this:

\command word1 word2 ... n-word --> Word1 Word2 ... n-Word

with first letter bold and capital. I wrote this:

\makeatletter % we need to use kernel commands
\newcommand{\boldAcr}{%

        \@boldAcrOne
    }
\newcommand\@boldAcrOne{
        \@ifnextchar\stopbold{\@boldSend}{\@boldAcrTwo}
    }

\newcommand\@boldAcrTwo[1]{%
        \@boldAcrThree{#1}

        \@boldAcrOne % restart the recursion
    }
\newcommand\@boldAcrThree[1]{%
        \fb{#1}
        }
\newcommand\@boldSend[1]{% The argument is \stopbold

}
\makeatother
\newcommand{\fb}[1]{\dofb#1}
\newcommand{\dofb}[1]{\MakeTextUppercase{\textbf{#1}}}

and then in the document

\boldAcr
{hello}{hi}
\stopbold

The result is:

Hello

Hi

but i would like the output to be in the same line. Is there a way to do that?

ScTALE
  • 389
  • I guess you should try to get rid of the blank lines in your code. You should also look into protecting line ends with % (https://tex.stackexchange.com/q/7453/35864). – moewe Jan 30 '19 at 11:13
  • You can make it much easier for people to help you if you combine your several code snippets into one fully working and compilable example document (an MWE: https://tex.meta.stackexchange.com/q/228/35864). – moewe Jan 30 '19 at 11:17
  • 2
    for example `\newcommand{\boldAcr}{%
        \@boldAcrOne
    }` inserts a paragraph break (from the blank line) and `\newcommand\@boldAcrOne{
        \@ifnextchar\stopbold{\@boldSend}{\@boldAcrTwo}
    }`  inserts spurious spaces before and after the word, from the newlines
    
    – David Carlisle Jan 30 '19 at 11:22

0 Answers0