TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Consider the following MWE:

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

\begin{document}
a << b
\end{document}

When compiling, the two "<" characters get replaced by a single "opening french quote" character (sorry, don't know its name).

Is there a way to avoid this behaviour (besides using math mode) ?

Edit: I know I can get around with a $<<$ b or (as suggested in comments) with a {<}< b, or with verbatim mode. My question can be rephrased as:

Is there a way to tell Latex NOT to do these automatic character replacements?

share|improve this question
    
Use case: I am putting up some course text documents on OSes, and appending to a file gets written a >> b. – kebs 17 hours ago
    
Do you want to suppress the ligature always or only in some cases? – Ulrike Fischer 17 hours ago
2  
Well, a {<}< b certainly would get around the ligature. – Steven B. Segletes 17 hours ago
1  
Well, considering that both Ulrike and I weren't sure whether you were looking for a one-off or a global solution, perhaps you should edit your question to clarify exactly what you are looking for. Remember, we don't necessarily have a sense of your experience level with LaTeX. – Steven B. Segletes 17 hours ago
1  
looks like you are looking for some verbatim rendering, hence try \verb@a <<b@ or in a verbatim environment. – jfbu 17 hours ago

For locally disabling the ligature you have several methods:

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

\begin{document}
a << b

a <{}< b

a {<}< b

a <\/< b

a <\textcompwordmark< b

\end{document}

I'd prefer the one with \/, because it's engine independent; the same example (but with fontspec) in LuaTeX

\documentclass{article}    

\usepackage{fontspec}

\begin{document}
a << b

a <{}< b

a {<}< b

a <\/< b

a <\textcompwordmark< b

\end{document}

would give

enter image description here

because LuaTeX ignores braces when doing ligatures.

Of course, the best thing is to define a personal command, so you can modify the rendering without chasing the document for <\/<:

\newcommand\textll{<\/<}

and

a \textll{} b

When somebody will tell you that some negative kerning must be applied between the less than symbols, you'll be happy of having preferred an abstract method.

Side note: this assumes the OT1 encoding is not used; with it the input << would not produce a ligature, but ¡¡ (two reverse exclamation marks); the ligature << for a left guillemet is only active in the T1 encoding (and possibly LY1) and, with fontspec and (Xe|Lua)LaTeX, for fonts loaded with the Ligatures=TeX option.

share|improve this answer
    
you might comment (re engine independence) that with original knuth tex, the < would be rendered as an upside down exclamation point. the \/ doesn't overcome that. probably irrelevant for most people these days, but there are still some "holdouts". – barbara beeton 16 hours ago
    
Thanks for answer. Solution 4 & 5 is indeed what I want. And defining a new command does seem a good option. – kebs 16 hours ago
    
Another engine-independent method worth mentioning is the insertion of an explicit kern, e.g., \kern0pt. – Mico 12 hours ago
    
@Mico Yes, \/ is indeed an explicit kern. – egreg 12 hours ago
    
@barbarabeeton the engine isn't really the issue there (you'd get Spanish punctuation by default in (say) xelatex as well, it's the font (and font encoding) that matter so anything using computer modern will do that. – David Carlisle 11 hours ago

If you want it globally you can use microtype:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\DisableLigatures[<]{encoding = T1}
\begin{document}
a << b
\end{document}

enter image description here

share|improve this answer
    
Thanks, never used that package, just learned something today! – kebs 17 hours ago
1  
Since the user (@kebs) says (s)he has never used the microtype packages, I think it would be useful to add a notice to clarify that loading it affects the typesetting well beyond the sheer fact of making it possible to suppress ligatures. – Gustavo Mezzetti 8 hours ago
    
@GustavoMezzetti: I still hope that users at least skim a few pages of the documentation before using an unknown package. – Ulrike Fischer 55 mins ago

In the comments it was specified that this is actually bash source code. So LaTeX should know that it is bash source code. This can be done be using, e.g., the listings package:

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

\usepackage{listings}
\lstset{basicstyle=\ttfamily}

\begin{document}
As listing:
\begin{lstlisting}[language=bash]
a << b
\end{lstlisting}

Inline:
\lstinline[language=bash]{a << b}
or
\lstinline[language=bash]/a << b/
\end{document}
share|improve this answer

For the case of math type setting:

\documentclass{article}
\begin{document}
\[ a \ll b \]
\end{document}

Result

And with amssymb:

\documentclass{article}
\usepackage{amssymb}
\begin{document}
\[ a < b \ll c \lll d \]
\end{document}

Result with amssymb

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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