3

I am trying to redefine \bfseries to become a spacing-out command. The easiest way is to redefine it as \so macro from the soul package. The trouble is, \so takes an argument (and thus is analogous to \textbf).

Is there a good way to have a macro with the \bfseries syntax, which produces a letterspacing output (and also takes care of robustness)?

5
  • Have a look at the soul package manual, Section 7 "How the package works": "L e t t e r s p a c i n g , underlining, striking out and highlighting use the same kernel. It lets a word scanner run over the given argument, which inspects every token." So, it needs to use an argument and is only really intended for shorter portions of text. Feb 28, 2018 at 13:26
  • 4
    why take an existing command name and change its interface to take an argument? redefining something from bold to letterspace is reasonable but redefining the syntax can surely only lead to problems, why not use a new command name, or keep the existing syntax? Feb 28, 2018 at 13:30
  • @DavidCarlisle Yes, that would be easy. But I want to have a command that mimics \bfseries syntax, but produces the \so output. Actually, my question was misleading, correcting it now.
    – Jabot
    Feb 28, 2018 at 13:36
  • @MartinScharrer OK, that's fair enough. Though I do not intend to use it for long portions of text. I think there is a general problem here too: can we define a macro taking no argument like \bfseries via a macro that takes one?
    – Jabot
    Feb 28, 2018 at 13:46
  • 1
    @Jabot the answer to your most general question is no. But in practice you pretty well always have some context specific way of grabbing the text as a macro argument. Perhaps you should ask a specific question about the case you have. Feb 28, 2018 at 15:08

1 Answer 1

8

You could use \lsstyle from the microtype package:

\documentclass[a4paper,12pt]{article}
\usepackage{microtype}
\begin{document}

{\lsstyle some text letterspaced} some text not letterspaced

\end{document}

enter image description here

With xelatex you can do something like this (instead of redefining \lsstyle you can define your own command):

\documentclass[a4paper,12pt]{article}
\usepackage{fontspec}
\setmainfont{Latin Modern Roman} %needed for addfontfeature
\usepackage{microtype,ifxetex}
\ifxetex
 \AtBeginDocument{\renewcommand\lsstyle{\addfontfeature{LetterSpace=5}}}
\fi 
\begin{document}

{\lsstyle some text letterspaced} some text not letterspaced

\end{document}

enter image description here

2
  • I was aware of that possibility, but couldn't remember what was wrong with it. Now I do: letter spacing in microtype does not work with xetex. Still, as of now, this is the only solution.
    – Jabot
    Mar 1, 2018 at 7:59
  • 1
    I added an edit for xelatex. Mar 1, 2018 at 8:22

You must log in to answer this question.

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