# Define commands without the right bracket

Is it possible to define a command without using the double left and right brackets? There are many occasions where I forgot to put the right bracket in a very long text and I spend enough time to find the missing bracket. For example, I would like to define a command that replace the \textbf{boldtext} with a new command something like \boldf/boldtext, or \boldf^boldtext or \boldf~boldtext or \boldf@boldtext( or something similar. I dont care about /, ^ or ~ etc. These will play the role of the left bracket) . Of course a space or a dot or a question mark etc. will play the role of the right bracket of the command.

• Have a look at xparse. You can define commands with any delimiter you want. Just typeset the argument in \bfseries. – TeXnician Feb 9 '17 at 8:15
• How should TeX know where the argument ends? You can use \def with basically any delimiter, but the right one is necessary – user31729 Feb 9 '17 at 8:21
• This seems to be a duplicate of a question asked yesterday, I gave an answer there (just change \ttfamily to \bfseries) but note the commentary on that question: you do not want to do this! tex.stackexchange.com/questions/352811/… – David Carlisle Feb 9 '17 at 8:53
• This is more of an editor problem. Any well-bred editor, when you type an opening brace will automagically type the corresponding closing brace, and the cursor in-between. – Bernard Feb 9 '17 at 10:00
• What about \textbf{All this text should be bold} and this text is normal? How do you propose to cope with it? – egreg Feb 9 '17 at 11:53

I don't recommend this in general. There might be occasions where this needed, but not for pure lazyness ;-)

It is possible to define commands with 'arbitrary' delimiters with \def, for example.

\def\boldf/#1 {%
\textbf{#1}%
}


will use the / as left delimiter and (note the space between #1 and {) a space character as right delimiter.

\documentclass{article}

\begin{document}

\def\boldf/#1 {%
\textbf{#1}%
}

\boldf/foo \boldf/foobar

\end{document}

• The code works nice! Just remember to place a space. So \boldf/haveagoodday! is different from \boldf/haveagoodday ! – kornaros Feb 9 '17 at 21:26
• @kornaros: Yes, but you see, that there is not really a benefit each way. You need a right delimiter, call it } or ! or whatever, it can be even another command, but it must be there. – user31729 Feb 9 '17 at 21:35