Text FormattingAutomatic Insertion of unbreakable Space after Guillemets

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
AleCes
Posts: 286
Joined: Sat Nov 13, 2010 9:54 pm

Re: Automatic Insertion of unbreakable Space after Guillemet

Post by AleCes »

Pardon my ignorance, but which is the "Unicode character for guillemets"?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10340
Joined: Mon Mar 10, 2008 9:44 pm

Automatic Insertion of unbreakable Space after Guillemets

Post by Stefan Kottwitz »

Here are the codes: Guillemet Unicode. You could also copy & paste such characters into your code.

With pdfLaTeX:

Code: Select all

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\begin{document}
«~Text~»
\end{document}


With XeLaTeX:

Code: Select all

\documentclass{article}
\usepackage{fontspec}
\begin{document}
«~Text~»
\end{document}
Stefan
LaTeX.org admin
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Automatic Insertion of unbreakable Space after Guillemets

Post by localghost »

To elaborate Stefan's answer regarding XeLaTeX a bit, here's an example for a French document.

Code: Select all

% !TeX program = xelatex
\documentclass[11pt,a4paper]{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\setdefaultlanguage{french}

\setmainfont[Ligatures=TeX]{XITS}
\setsansfont[Ligatures=TeX,Scale=MatchLowercase]{Cantarell}
\setmonofont[Ligatures=TeX]{Inconsolata}
\setmathfont[Ligatures=TeX]{XITS Math}

\begin{document}
  «Text»: «Text»;
\end{document}
All used fonts are available for free in the net.
AleCes
Posts: 286
Joined: Sat Nov 13, 2010 9:54 pm

Automatic Insertion of unbreakable Space after Guillemets

Post by AleCes »

Ahem... I don't understand your point. Of course my font, Tinos supports Unicode-compliant guillemets. I mean, I'm not enjoining XeLaTeX to fake them through bitmaps. But the main issue here is: how do I type them time-effectively into my text, provided that, as you probably know, the French layout does not contain a key for them? Copy-paste is annoying, especially when you (like me) deal with a book, a very long text. I was wondering whether LaTeX allows for some quick-and-dirty shortcuts, something like \S for the section sign (§).
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Automatic Insertion of unbreakable Space after Guillemets

Post by localghost »

AleCes wrote:[…] But the main issue here is: how do I type them time-effectively into my text, provided that, as you probably know, the French layout does not contain a key for them? […]
Hm, from a French keyboard I would think that it has keys to produce these characters directly. On my Linux system I just need to hold "Alt Gr" and hit "x" to produce "«". For "»" it's "Alt Gr" together with "y". Doesn't your editor allow a setup to insert these French quote characters directly by replacement?
AleCes
Posts: 286
Joined: Sat Nov 13, 2010 9:54 pm

Automatic Insertion of unbreakable Space after Guillemets

Post by AleCes »

Oops, I forgot about that, here's the workaround I devised:

Code: Select all

\newcommand{\og}{«}
\newcommand{\fg}{»}
Hope it might help other people.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Automatic Insertion of unbreakable Space after Guillemets

Post by Johannes_B »

Please note something: I had french in school, but this is a long long time ago. I don't know about Stefan or Thorsten. And tough I actually learnt the language. i can't remember for the life of me about the Punctuation rules of the french language. I guess it's the same about the others.

If this really is common orthography, then there will already be a solution.

And now please consider the following MWE:

Code: Select all

\documentclass{book}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{french}
\usepackage{csquotes}
\begin{document}
This is a \enquote{Test sentence}: My french is a bit rusty.
\end{document}

Code: Select all

\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{csquotes}
\begin{document}
This is a \enquote{Test sentence}: My french is a bit rusty.
\end{document}
EDIT: I just read the thread from the beginning, and altough you mentioned french typography your problem description was completely wrong.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
AleCes
Posts: 286
Joined: Sat Nov 13, 2010 9:54 pm

Automatic Insertion of unbreakable Space after Guillemets

Post by AleCes »

Johannes_B wrote:Please note something: I had french in school, but this is a long long time ago. I don't know about Stefan or Thorsten. And tough I actually learnt the language. i can't remember for the life of me about the Punctuation rules of the french language. I guess it's the same about the others.

If this really is common orthography, then there will already be a solution.

And now please consider the following MWE:

Code: Select all

\documentclass{book}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{french}
\usepackage{csquotes}
\begin{document}
This is a \enquote{Test sentence}: My french is a bit rusty.
\end{document}

Code: Select all

\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{csquotes}
\begin{document}
This is a \enquote{Test sentence}: My french is a bit rusty.
\end{document}
EDIT: I just read the thread from the beginning, and altough you mentioned french typography your problem description was completely wrong.
OK, I'm sorry, you know I'm a rookie, my understanding of Latex is very limited.

Now, \enquote is could be useful because polyglossya doesn't make any allowance for French-style quotes but if you use babel, you won't need it as it enables the commands \og and \fg, which respectively open and close the angle quotes and places an unbreakable space respectively after and before the said quotes. The unbreakable space is mandatory in French, does \enquote do so? Otherwise it won't be any good.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Automatic Insertion of unbreakable Space after Guillemet

Post by Johannes_B »

enquote changes the quotes acccording the language.
If enquote adds he mandatory space? Try clicking on my given example.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
AleCes
Posts: 286
Joined: Sat Nov 13, 2010 9:54 pm

Automatic Insertion of unbreakable Space after Guillemets

Post by AleCes »

Johannes_B wrote:enquote changes the quotes acccording the language.
If enquote adds he mandatory space? Try clicking on my given example.
I've already done so, of course, before answering you. The problem is, is the space a normal one or an unbreakable one? How can I tell it?
Post Reply