2

I need to put expressions containing "<" and ">" sign in italics. For example, GenericPositive

However, when I do

\textit{GenericPositive<Type>}

it does not display the "<" or ">" signs. I also tried to add a slash so:

\textit{GenericPositive\<Type\>}

but it doesn't work either. What is more, I also tried the math mode with "$" signs so:

$GenericPositive$

and it does display the "<", ">" signs but then the whole expression gets split between different lines of text and I don't want that to happen.

What can I do to see "<" and ">" in an expression in italics in such a way that this expression is not split between different lines of text?

  • 3
    Please provide a minimal example (a full but minimal document we cqan copy and test as is). For me they appear if I add \usepackage[T1]{fontenc} to a super simple minimal doc – daleif Jun 27 at 12:56
  • @daleif This solved the problem. Thank you so much – Ewelina Jun 27 at 13:03
  • Do you really want the <> symbols in italics? I'd recommend using angle brackets, instead, and always upright. – egreg Jun 27 at 13:44
4

I take it that you use pdfLaTeX and the "original", aka OT1, font encodings.

I have two suggestions:

  • If, for some reason, you can't or mustn't switch to the newer T1 font encoding, you could write

    \textit{GenericPositive\textless Type\textgreater}
    
  • As @daleif has already noted in a comment, the problem vanishes if you include the instruction

    \usepackage[T1]{fontenc}
    

    in the preamble.

1

It seems to me that you want to typeset source code. If that is the case I would highly recommend to use a specialized package for that like minted. Please note that minted depends on python and pygments and therefore requires the -shell-escape flag as described in sections 2.1 and 3.1 of it's documentation.

I don't know what language you want to use so I am inserting a LaTeX example:

\documentclass{article}
\usepackage{minted}

\setminted{autogobble, breaklines}

\begin{document}
A block of code:
\begin{minted}{latex}
    \documentclass{beamer}

    \begin{document}
    \begin{frame}
    \begin{center}
        \uncover<+->{Hello}
        \uncover<+->{World}
    \end{center}
    \end{frame}
    \end{document}
\end{minted}

Or inline:
\mintinline{latex}{\uncover<+->{Hello}}
\end{document}
  • Please clarify how your answer addresses the OP's stated objective, "I need to put expressions containing "<" and ">" sign in italics." – Mico Jun 27 at 14:04

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.