2

Microtype's \lsstyle seems to cause problems related to math mode, which have been the subject of a few questions already (I must confess to not understanding it all).

I'm dealing with a behavior that seems math mode-related, but can't even understand the “pattern” of the problem.

In the following MWE, the command \ecl{} followed by a space should induce a space in the output. For some reason, if it is called after a \lsstyle, it does not have that following space on its first appearance, but it does have it for the ones after that. I understand neither behavior. Any ideas as to what causes them, and how to fix it?

    
    \documentclass{article}
    \usepackage [%
                    letterspace=50% for \textls{} and {\lsstyle }
                ]
                {microtype}
    
    \newcommand\ecl[1]
                {%
                    \textnormal{$\langle$#1$\rangle$}%
                }
    
    \begin  {document}
            
            \lsstyle
            
            Some text
            \ecl{A} B %the space after "\ecl{A}" is somehow "cancelled"
            and more text
            \ecl{A} B %that same space appears as expected
            and more text
            
    \end    {document}

2 Answers 2

1

I didn't trace everything (using nested font changes and math within letterspaced section is unusual...)

But you can add a box to prevent the lookahead

enter image description here

\documentclass{article}
    \usepackage [%
                    letterspace=50% for \textls{text} and {\lsstyle }
                ]
                {microtype}
    
    \newcommand\ecl[1]
                {%
                    \textnormal{$\langle$#1$\rangle$}\mbox{}%
                }
    
    \begin  {document}
            \lsstyle
            
            Some text
            \ecl{A} B %the space after "\ecl{A}" is somehow "cancelled"
            and more text
            \ecl{A} B %that same space appears as expected
            and more text
            
    \end    {document}
4
  • Thanks a lot, @David Carlisle. I just noticed defining \ecl{} as "{\rm $\langle$#1$\rangle$}" does the trick too. Not sure why!
    – Rpy
    Commented Nov 11, 2023 at 10:48
  • @Rpy \rm has been deprecated for about 30 years.
    – egreg
    Commented Nov 11, 2023 at 13:21
  • @Rpy don't use \rm it's not defined by default. \text... commands look ahead for italic correction which is probably the issue here Commented Nov 11, 2023 at 13:36
  • Thank you very much! :)
    – Rpy
    Commented Nov 11, 2023 at 18:23
1

It's the math mode that somehow has problems. However, you want \textlangle and \textrangle.

\documentclass{article}
\usepackage[
  letterspace=50,
]{microtype}

\newcommand\ecl[1]{%
  \textnormal{\textlangle #1\textrangle}%
}

\begin{document}

\lsstyle

Some text \ecl{A} B and more text \ecl{A} B and more text

\end{document}

enter image description here

1
  • I didn't know these existed in text mode—thanks a lot!
    – Rpy
    Commented Nov 11, 2023 at 18:24

You must log in to answer this question.

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