Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

textcolor consumes whitespaces #1474

Open
LupinoTech opened this issue Sep 20, 2024 · 2 comments
Open

textcolor consumes whitespaces #1474

LupinoTech opened this issue Sep 20, 2024 · 2 comments
Assignees
Labels
bug (improve documentation) nothing really wrong but documentation could be better category graphics wont fix/change/enhance something that might be desirable but ...

Comments

@LupinoTech
Copy link

Whitespaces after the opening brace of the text argument of \textcolor{<color>}{ <text>} consumes the whitespace, while other \text-Macros (like \textbf{ }) don't consume trailing whitespaces. I would like to suggest to ensure that all \textXY macros behave the same way when it comes to trailing spaces.

\RequirePackage{latexbug}
\documentclass{article}

\title{}
\author{}
\usepackage{color}
\parindent0pt

\begin{document}
Foo\textcolor{red}{ Bar}

Foo\textbf{ Bar}
\end{document}

(same with xcolor instead of color)
test.log

A potential fix could be to define \@textcolor as \def\@textcolor#1#2#3{\protect\leavevmode{\color#1{#2}\relax#3}} to eliminate the effects of the \ignorespaces that comes with \color, iff the community decides that this is an issue and that \textcolor{} should behave like \textbf{}.

@davidcarlisle
Copy link
Member

davidcarlisle commented Sep 20, 2024

\color has \ignorespaces so that

Foo\color{red}     Bar

acts like

Foo\bfseries    Bar

and drops the spaces, although of course the space dropping is happening at a different level and

Foo\bfseries\space Bar

has a space whereas

Foo\color{red}\space Bar

does not.

The case shown is effectively an instance of ths second case where pre-tokenised spaces are dropped for color but not a font change.

The change you show would of course have the effect described, but I do wonder if it's safe to change the spacing here after 30 years, especially as other cases with pre-tokenized spaces would still show differences.

@LupinoTech
Copy link
Author

The change you show would of course have the effect described, but I do wonder if it's safe to change the spacing here after 30 years, especially as other cases with pre-tokenized spaces would still show differences.

probably not. Maybe one could give a simple package option that if set preserves spaces, and if not set, it keeps the old behavior?

@josephwright josephwright added bug (improve documentation) nothing really wrong but documentation could be better wont fix/change/enhance something that might be desirable but ... labels Oct 22, 2024
@josephwright josephwright added this to the Release 2025 Spring milestone Nov 6, 2024
@github-project-automation github-project-automation bot moved this to Pool (unscheduled issues) in upcoming LaTeX2e releases Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug (improve documentation) nothing really wrong but documentation could be better category graphics wont fix/change/enhance something that might be desirable but ...
Projects
Status: Pool (unscheduled issues)
Development

No branches or pull requests

5 participants