# How to undo bold and italic text in braces?

Is there a command to nullify, override or cancel any font style in the text in braces?

Something like:

\nullifystyle{sample text: \textit{this should be not italic} and \textbf{this should be not bold}}

\normalfont, \textnormal,\textup and \upshapedo the very opposite. See: How to set not italic or not bold?

Use case: I need it to recall pieces of text from other part of the document, but to override the font style. A MWE would be:

\documentclass{article}

\begin{document}

\newcommand{\nullifystyle}{???} %is there already a command for this? or how to define it?

\newcommand{\textsample} {some normal text, \textit{some italic} and \textbf{some bold}}

Here I would like to write \textsample. \par

Here  \nullifystyle{\textsample} \ should be typed  totally with normal font style.

\end{document}

• What exactly do you want to do, i.e. what's the use case for this? – remco Mar 21 '18 at 9:52
• @remco I edited the question with a MWE, thanks – peppino Mar 21 '18 at 10:50
• I still don't see in what kind of situations you would use this. Is it possible to enlighten us? The best thing I can think of is something like "note that if you send the text given above in a telegram, it will lose the formatting and just look like this: ...". – pst Mar 21 '18 at 12:48
• @pst in the document I'm compiling I decided that Section Titles must not have any word in italic (e.g. foreign words). But when i recall section title name with \nameref the italic words must be correctly typesetted. So this command is pretty useful. – peppino Mar 21 '18 at 12:56

Locally redefine \selectfont not to honor changes in shape and series:

\documentclass{article}

\makeatletter
\newcommand{\nullifystyle}[1]{%
\begingroup
\edef\sv@f@shape{\f@shape}%
\edef\sv@f@series{\f@series}%
\let\sv@selectfont\selectfont
\def\selectfont{%
\fontshape{\sv@f@shape}%
\fontseries{\sv@f@series}%
\sv@selectfont
}%
#1%
\endgroup
}
\makeatother

\begin{document}

\nullifystyle{sample \emph{text}: \textit{this should be not italic}
and \textbf{this should be not bold}\textsuperscript{test}}

\end{document}


It works the same if you use a macro like in your example

\newcommand{\sampletext}{sample \emph{text}: \textit{this should be not italic}
and \textbf{this should be not bold}\textsuperscript{test}}

\nullifystyle{\sampletext}

• This also works pretty well! – peppino Mar 21 '18 at 11:14
• @peppino It doesn't require to know in advance what commands to nullify. – egreg Mar 21 '18 at 11:16

You could redefine the commands that you need to nullify something like the following.

\documentclass{article}

\newcommand\noop[1]{#1}
\newcommand\nullifystyle[1]{\begingroup\let\textit\noop\let\textbf\noop
#1\endgroup}

\begin{document}
\textit{This should be italic} and \textbf{this should be bold}.

\nullifystyle{\textit{This should not be italic} and \textbf{this
should not be bold}}.

\textit{This should be italic} and \textbf{this should be bold}.
\end{document}


But I think it would be best if you explained something of what you need this for, and then probably a better solution can be suggested.

• your solution works very well. I added a MWE to my question to give more context and see if other solutions are possible. – peppino Mar 21 '18 at 11:06