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:



\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.

  • 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:




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


enter image description here

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}}

  • 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.



\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}.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.