13

I want to get this style of hanging punctuation: Hanging punctuation

Quotation marks «...» „...“, brackets (...) [...] {...} and bullets are put beyond the left margin.

Quotation marks, brackets, periods, and commas are set outside the right margin. Hyphens (both in compound words and between the syllables of a word that’s divided at the end of a line) should not fall outside the margin full-length, but rather be hung one third or half of their length.

I try to achieve this by using the \SetProtrusion command according to the manual (page 12):

% !TeX encoding = UTF-8
% !TeX TS-program = lualatex
\documentclass[a4paper,14pt]{extarticle}
\usepackage[russian]{babel}
\usepackage{fontspec}
\usepackage{xltxtra}
\usepackage{csquotes}
\defaultfontfeatures{Renderer=Basic,Mapping=tex-text,Scale=MatchLowercase}
\setmainfont{Charis SIL}[Mapping=tex-text,Scale=MatchLowercase]
\setromanfont{Charis SIL}[Mapping=tex-text,Scale=MatchLowercase]
\setsansfont{PT Sans}[Mapping=tex-text,Scale=MatchLowercase]
\setmonofont{PT Mono}[Mapping=tex-text,Scale=MatchLowercase]
\usepackage[protrusion=true,expansion=true,final,babel=true,factor=2000]{microtype}
\SetProtrusion 
{encoding = *}
{
    \textquotedblleft = {4000, },
    \textquotedblright = { ,4000},
    . = { , 4000}
    « = {4000, },
    » = { ,4000},
    ( = {4000, },
    ) = { ,4000}
}

\begin{document}
\noindent\enquote{Окончательная машинописная рукопись основана на отредактированном третьем варианте и, после того как она готова, ее \enquote{читают} и правят, и правят заново.
Приблизительно через два) года после начала работы (два рабочих года! Они могут быть. намного длиннее двух календарных лет...) книга отсылается в} издательство.\\
«Окончательная машинописная рукопись  основана на отредактированном третьем варианте и, после того как она готова, ее (читают и правят, и правят заново.
Приблизительно через два) года после начала работы (два рабочих года! Они могут быть. намного длиннее двух календарных лет...) книга отсылается в» издательство....
\end{document}

But it doesn't work:

enter image description here

(If it matters, I use LuaLaTeX from MikTeX on Windows 7)

  • 1
    The fontspec commands take the optional argument after the name of the font, e.g., \setmainfont{Charis SIL}[Ligatures=TeX]. – Manuel Jun 29 '15 at 17:30
  • probably not relevant, but the hyphens in the second example look very narrow, and splitting them in half wouldn't have much effect. – barbara beeton Jun 29 '15 at 17:41
  • @Manuel -- For the record: both syntactic formats (optional arguments before or after the mandatory argument) of fontspec's font-related directives work equally well. – Mico Jun 29 '15 at 20:52
  • 1
    @Mico It lead me to a problem in the past :) But I still don't get your point, really. Both work equally well, yeah, one is the official way, and the other one is just for compatibility. I don't see the point of reminding that both work, I think it's better to recommend the official way. (To me it's similar —not equal— as if someone reminded that {\bf this} gives bold font instead of just recommending \textbf{this}.) – Manuel Jun 29 '15 at 21:22
  • 1
    @Manuel - My point is that there's no problem pointing out that the optional arguments can come after rather than before the mandatory argument if you also point out that both orderings produce identical results -- and will continue to do so indefinitely. This is quite different from the status of TeX macros such as \bf, \sl, and \it. The fontspec manual (see esp subsection 5.5, "Miscellaneous font selecting details") takes care to point out that "backwards compatibility has been preserved". – Mico Jun 30 '15 at 3:36
16

Your settings are never applied because in the first argument to \SetProtrusion you only specify the encoding. microtype will always try to load the best matching settings, and since settings for Charis SIL exist, they will be applied instead. Drawing from this answer, you can overwrite settings by first loading the configuration file and then redefining these settings:

\usepackage[protrusion=true,expansion=true,final,babel=true]{microtype} % default factor (1000)
\LoadMicrotypeFile{CharisSIL}
\SetProtrusion
   [ name = Charis-default ]
   { }
   {
    \textquotedblleft = {1000, },
    \textquotedblright = { ,1000},
    \quotedblbase = {1000, }, % = „
    . = { , 1000}, % there was a comma missing here
   {,} = { , 1000}, % this comma needs to be masked 
    « = {1000, },
    » = { ,1000},
    ( = {1000, },
    ) = { ,1000},
    - = { ,500}
   }

For the other shapes, you can then simply load these settings:

\SetProtrusion
   [ name = Charis-it,
     load = Charis-default ]
   {}{}
\SetProtrusion
   [ name = Charis-sc,
     load = Charis-default ]
   {}{}

(I must say that I find these settings weird, since they are contrary to the idea that microtypographical tweaks should be discreet and not jump out at the reader – as elaborated 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.