How to Define a Command for Italic Text in LaTeX
At a glance
- 1. Choose the mode
Use text italics in ordinary prose; use math-mode commands for symbols and expressions.
- 2. Define the argument
If the command takes text as input, declare one argument with [1] and refer to it as #1.
- 3. Call the command
Write the command followed by its argument in braces, and compile the minimal example.
If a command intended to italicize text fails, the usual causes are a missing argument declaration or using a text-formatting command in math mode. For ordinary prose, define a command with \textit{#1} and declare one argument with [1].
Define a command with one text argument
Use this form in the preamble, before \begin{document}:
\newcommand{\myital}[1]{\textit{#1}}
Here, \myital is the command name, [1] says it takes one argument, and #1 marks where that argument goes in the replacement text. Use it like this:
This word is \myital{emphasized}.
The braces delimit the argument. The result is ordinary text with “emphasized” set in italics.
Complete working example
This minimal document needs no extra package:
\documentclass{article}
\newcommand{\myital}[1]{\textit{#1}}
\begin{document}
This word is \myital{emphasized}.
The command also works with a longer phrase: \myital{italic text in a sentence}.
\end{document}
The definition belongs in the preamble so it is available throughout the document. The command can be used more than once, with a different braced argument each time.
Why a definition may fail
The argument count is missing. If the replacement text contains #1, the definition must declare at least one argument. This definition is incomplete and causes an error:
\newcommand{\myital}{\textit{#1}}
Write \newcommand{\myital}[1]{\textit{#1}} instead. For two arguments, declare [2] and use #1 and #2 in the replacement text.
The command is being used in math mode. \textit formats text; it is not the usual way to italicize a mathematical symbol. For a math symbol or expression, use a math-mode command:
$\mathit{AB}$
For ordinary words inside a formula, use \text{...} from the amsmath package. For example, \usepackage{amsmath} in the preamble enables $x \text{ is positive}$. If you specifically want those words italic, you can use \text{\textit{positive}}.
The command is used without its argument. After defining a one-argument command, supply the argument in braces: \myital{word}. A bare \myital does not provide the intended text.
The name has already been defined. \newcommand reports an error if the command name already exists. Choose a new name, or use \renewcommand only when you deliberately intend to replace an existing definition.
Italics and emphasis are not quite the same
For a reusable formatting command, \textit{...} is explicit. In prose, \emph{...} is often better when the goal is emphasis rather than a fixed italic appearance: LaTeX can change the emphasis style when it occurs inside already-emphasized text. If the request is specifically for italic text, \textit is appropriate.
If a definition still fails, check the exact error message and the mode where the command is called. A short document containing only the preamble definition and one use, like the example above, makes it easier to isolate the problem.
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.