Text FormattingSpecial Characters in Argument of a new Command

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
evans
Posts: 5
Joined: Tue Apr 24, 2012 2:51 pm

Special Characters in Argument of a new Command

Post by evans »

Hi friends,

I have a LaTeX class in which I define a new command as:

Code: Select all

\newcommand{\bb}[1]{\textbf{\textcolor{red}{#1}}}
The command works fine with normal text without any formatting but when I try a text with special characters, like \bb{Al\'{e}s} I get this error:

Code: Select all

!Missin } inserted
1.18 \bb{Al\'{e}s}
I will appreciate any help. Thank you in advance.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Special Characters in Argument of a new Command

Post by Stefan Kottwitz »

Hi Evans,

the code is working, the error must be caused earlier. Try this:

Code: Select all

\documentclass{article}
\usepackage{color}
\newcommand{\bb}[1]{\textbf{\textcolor{red}{#1}}}
\begin{document}
\bb{Al\'{e}s}
\end{document}
It works fine for me. Check the lines before, and perhaps post a Infominimal working example which shows the error when compiled.

Stefan
LaTeX.org admin
evans
Posts: 5
Joined: Tue Apr 24, 2012 2:51 pm

Special Characters in Argument of a new Command

Post by evans »

Hi Stefan_K,
Thank you for the answer but it works fine like the way you said but i have the command in my customized class:

Code: Select all

\def\currversion{April 17, 2012}
\typeout{LaTeX class for TEST alphabetical display of thesaurus terms.}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{testClass}
\LoadClass[12pt]{article}
\RequirePackage{cantarell}
\RequirePackage{multicol}
\RequirePackage{color}
\RequirePackage[english,french,german,italian]{babel}
\RequirePackage[utf8]{inputenc}
\RequirePackage[T1]{fontenc}
\newcommand{\bb}[1]{\textbf{\textcolor{red}{#1}}}
\renewcommand{\familydefault}{fca}
\newcommand{\nt}{\>NT \=}
\newcommand{\push}{\>\>}
\newcommand{\rt}{\>RT \=}
\newcommand{\bt}{\>BT \=}
\newcommand{\uf}{\>UF \=}
\newcommand{\topt}{\>TT \=}
\newenvironment{mytabbing}{\begin{tabbing}
\hspace{0.50 cm}\= \\ }
{\end{tabbing}}
\setlength{\parindent}{0in}
and then when I use this class in my documentclass like:

Code: Select all

\documentclass{testClass}
\begin{document}
\begin{mytabbing}
\bb{Al\'{e}s}
\end{mytabbing}
\end{document}
when the \bb{Al\'{e}s} comes within the mytabbing environment, I get the error:
!Missin } inserted
1.18 \bb{Al\'{e}s}
but outside of it it works fine. Thank you.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Special Characters in Argument of a new Command

Post by Stefan Kottwitz »

The problem is, that you used the accent command \' within a {tabbing} environment, where the shortcut \' has a different meaning. You can fix it by writing \a' instead:

Code: Select all

\begin{mytabbing}
\bb{Al\a'{e}s}
\end{mytabbing}
Stefan
LaTeX.org admin
evans
Posts: 5
Joined: Tue Apr 24, 2012 2:51 pm

Re: Special Characters in Argument of a new Command

Post by evans »

Thank you so much Stefan. It works now.
Evans
Post Reply