23

I have the following piece of text which I want to output literally: <<"Welcome">>. However it's converted to those funky quotations. I've been trying all sorts of things with \ mostly but to no avail.

\verb=!<<"Welcome">>! kind of works, or gets the job done, but then it loses all other formatting (font face, size, etc.) as well.

2

4 Answers 4

16

A quick solution would be to use inline math mode: $<<$``Welcome''$>>$

edit: if you want to preserve formatting, have you considered \textgreater and \textless ?

1
  • 1
    No I haven't, but I'll google what they are about!
    – Till
    Feb 13, 2011 at 21:10
13

I don't think the less-than and greater-than signs are that pretty here. You might try instead:

  • $\langle\langle$``Welcome''$\rangle\rangle$ for angle brackets that are narrower and taller than the mathematical relations.
  • \guillemotleft``Welcome''\guillemotright for french quotation marks. Make sure you also have \usepackage[T1]{fontenc} in the preamble.

enter image description here

To be honest I don't think any of those look that pretty, but it is what you asked for. :-D

3
  • 1
    And $\ll$, $\gg$
    – Leo Liu
    Feb 13, 2011 at 20:12
  • @Leo Liu: good one. I added it to my answer. Feb 13, 2011 at 20:23
  • 1
    It's a code listing. I have pretty much no control over what it says and I need to display it. Thanks though, I learned a lot!
    – Till
    Feb 13, 2011 at 21:10
8

This may be what you want:

enter image description here

\documentclass{article}
\usepackage[T1]{fontenc}

\begin{document}

\guillemotleft``Welcome''\guillemotright

\end{document}

For code listing, you can use listings package:

enter image description here

\documentclass{article}
\usepackage[T1]{fontenc}

\usepackage{listings}
\lstset{
  basicstyle=\ttfamily,
  columns=fixed,
  literate={<<}{\guillemotleft}1 {>>}{\guillemotright}1
}

\begin{document}

\lstinline!<<"Welcome">>!

\end{document}

You can modify the literate as you wish.

4
  • Looks pretty sweet and I salute you for you fu! Unfortunately, it's a code listing. But I will keep this in mind!
    – Till
    Feb 13, 2011 at 21:09
  • @Till: You didn't mention that. My previous solution use lisings package especially for code listing. But I thought it's normal text and deleteted it. You may have a look at the edit history of this question (click the time after edited).
    – Leo Liu
    Feb 13, 2011 at 21:31
  • I recovered the previous solution.
    – Leo Liu
    Feb 13, 2011 at 21:34
  • Thanks for editing and extending your answer. I'll make sure to provide more details next time.
    – Till
    Feb 13, 2011 at 22:35
2

You can simply use brackets around one of your < or > symbol to avoid merging it with the second one. For example <{<}My text{>}>.

1
  • This implies << necessarily merges. Why is that?
    – Werner
    Jun 16, 2016 at 20:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .