Coder Social home page Coder Social logo

Comments (9)

davidcarlisle avatar davidcarlisle commented on May 10, 2024 1

Sorry I can't think of any reasonable example where a user facing command using xspace would have a bare \hbox. Document level boxes should always start with \leavevmode.
Thank you for the suggestion but I do not propose to make any changes here.

from latex2e.

FrankMittelbach avatar FrankMittelbach commented on May 10, 2024

please follow the issue template and provide workable test files that you have actually run next time :-) and the other components we ask for. In the long run this is helping everybody, thanks

from latex2e.

davidcarlisle avatar davidcarlisle commented on May 10, 2024

from latex2e.

eg9 avatar eg9 commented on May 10, 2024

The example code misses \usepackage{xspace}. Anyhow, \xspace should never be used in a document by itself, only as the last token in the definition of a parameterless macro.

Adding a space in vertical or math mode does nothing, so there's no point in checking for them.

from latex2e.

FrankMittelbach avatar FrankMittelbach commented on May 10, 2024

This really does fall under "works as designed", as explained it is inteded for a clearly defined use case and \xspace appearing in vmode or mmode is in fact an error on the programmers side using it (but at the same time adding a space in that mode doesn't do any harm either.

from latex2e.

FOCCOF avatar FOCCOF commented on May 10, 2024

But definitely, \xspace does not ONLY insert a space : it first looks for the next tokens. So there is no point to check next tokens if TeX is in vmode or mmode.

Nevertheless, I'll come later with an example, if this behaviour might be harmful somewhere, due to the looking forward of \xspace...

from latex2e.

FrankMittelbach avatar FrankMittelbach commented on May 10, 2024

The question is always how much you guard against incorrect usage. If you put a \chapter command into a \footnote it will blow up, but no we don't think it is worth testing if chapter is called inside a \insert.

Same here: \xspace is supposed to be used only after some text, so it is always by nature of supported use in hmode, so why should it test for that on any occasion if it shouldn't be ever in that situation (and if it is it is even fairly harmless)?
You really seem to have some use in mind for which it is not intended.

from latex2e.

FOCCOF avatar FOCCOF commented on May 10, 2024

Yes Frank, I know that. But things are not always so simple : suppose a command that typeset something in a \hbox, at the end there is \xspace.

But after the \hbox, TeX may be in vertical mode (as it was before the \hbox).

I'm not sure it's better for the user to check: \ifhmode \expandafter \xspace \fi than to the xspace command to perform the check.

Best regards.

from latex2e.

FOCCOF avatar FOCCOF commented on May 10, 2024

Alternatively, a test with \ifhmode can be considered as an optimisation, since nothing happens unless \ifhmode.

from latex2e.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.