r"""Make a string appear italicized in LaTeX formatting.

    italic() wraps a given string in the LaTeX command \textit{}.

    Args
    ----
    s : str
        The string to be formatted.
    escape: bool
        If true the italic text will be escaped

    Returns
    -------
    NoEscape
        The formatted string.

    Examples
    --------
    >>> italic("hello")
    '\\textit{hello}'
    >>> print(italic("hello"))
    \textit{hello}

def italic(s, *, escape=True):
    r"""Make a string appear italicized in LaTeX formatting.

    italic() wraps a given string in the LaTeX command \textit{}.

    Args
    ----
    s : str
        The string to be formatted.
    escape: bool
        If true the italic text will be escaped

    Returns
    -------
    NoEscape
        The formatted string.

    Examples
    --------
    >>> italic("hello")
    '\\textit{hello}'
    >>> print(italic("hello"))
    \textit{hello}
    """
    if escape:
        s = escape_latex(s)

    return NoEscape(r'\textit{' + s + '}')