12

Is there a way to directly input angle brackets into text without resorting to math-mode symbols?

I'd like to correctly indicate orthography in a linguistics paper, and have been resorting to single guillemots ‹ › as they are simple to type and display correctly. But I'd prefer to use angle brackets like ⟨ ⟩ . If I input these directly (U+27E8 and U+27E9), they don't display correctly—I prefer the Linux Libertine font family—but $\langle$ $\rangle$ display just fine. As the rest of my document(s) use UTF-8 and fontspec, I'd prefer not to clutter up the body text with math commands.

Is there a way around this?

8

fontspec doesn't have an interface for substituting some characters with characters from a different font, but thankfully egreg provided a package to do just that:

\documentclass{article}
\usepackage{fontspec}
\usepackage{newunicodechar}
\setmainfont{Linux Libertine O}

\newfontfamily\anglefont{Free Serif}    % Change to whatever font you prefer that has ⟨⟩.
\newunicodechar{⟨}{{\anglefont ⟩}}
\newunicodechar{⟩}{{\anglefont ⟨}}

\begin{document}
This is Linux Libertine with ⟨ and ⟩ from {\anglefont Free Serif}.
\end{document}

result

  • 1
    You can even say \newunicodechar{⟨}{{\anglefont ⟨}} No need to hunt through the Unicode character table. ;-) – egreg Mar 21 '12 at 17:30
  • N.B. The font name is "FreeSerif", without the space. If a space is used, the compiler will search all font directories, potentially including old TeX Live images. On systems like Overleaf, this can cause one to exceed compilation limits. Thanks to Dr. LianTze Lim for pointing this out to me! – Coby Viner Jun 18 at 2:08
6

You could employ the commands \textlangle and \textrangle provided by the textcomp package. If that's too many letters to type each time, you could define shortcuts for them, say \la and \ra. The following MWE illustrates this idea, also

% !TEX TS-program = xelatex
\documentclass{article}
\usepackage{fontspec}
% \setmainfont{Linux Libertine O} % select your main text font here
\usepackage{textcomp,    % for \textlangle and \textrangle macros
            xspace}
\newcommand\la{\textlangle\xspace}  % set up short-form macros
\newcommand\ra{\textrangle\xspace}
\begin{document}
\noindent
\textlangle\ and \textrangle; \newline 
\la and \ra.   % abbreviated macros; note: no need to insert explicit whitespace after "\la"
\end{document}

enter image description here

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.