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

Prevent double spacing in tcode #6200

Merged
merged 2 commits into from May 10, 2023
Merged

Conversation

morinmorin
Copy link
Contributor

@morinmorin morinmorin commented Mar 21, 2023

Due to nofrenchspacing, a space after ., :, ? are rendered as two spaces in monospaced fonts if these punctuations are preceded by non-capital characters. For example, \tcode{a ? b : c} is rendered as a ? b : c, and

\tcode{template <class... A> void f(A...) noexcept}

is rendered as

template <class...  A> void f(A...)  noexcept;

Currently, there are tens of these double spacings in the Standard.
This PR prevents them by adding \frenchspacing to CodeStylex.

@morinmorin
Copy link
Contributor Author

Diff screenshot.
frenchspacing

@morinmorin
Copy link
Contributor Author

morinmorin commented Mar 21, 2023

Defining \tcode using \lstinline would be far better. Benefits of \lstinline include

  • Single quotes are rendered as straight quotes (using upquote option).
  • No escape is needed; we can just write %, \, etc.
  • No double spacings.

\lstinline can be used with mathescape option. So we can use macros in $...$ e.g. using $\exposidnc{indirect-value-t}$ = $\seebelow$.

However, \lstinline behaves badly when used in macro arguments. For example, backslashes are used as escape characters in the TeX world and spaces before $ are not rendered. Thus, we cannot use \lstinline (unless this problem is resolved).

@jensmaurer
Copy link
Member

This now has overfull \hbox issues that need to be addressed.

@jensmaurer jensmaurer added the changes requested Changes to the wording or approach have been requested and not yet applied. label Mar 24, 2023
Copy link
Member

@jensmaurer jensmaurer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix overfull lines per "check-output.sh" results.

In `\nofrenchspacing`, a space after `.`, `?`, `!`, `:` are rendered as
two spaces in monospaced fonts if these punctuations are preceded by
non-capital characters. This can be fixed by adding `\frenchspacing`
to `CodeStylex`.
@morinmorin
Copy link
Contributor Author

morinmorin commented Mar 26, 2023

Thanks for the guidance. There are three overfull boxes.

  • ranges.tex (L10873–10878, std.pdf: p. 1225+10): 0.32013pt too wide

    • The offending word: \tcode{iterator_category}.
    • The overfullness is so small. This “overfull hbox” warning is suppressed by locally increasing \hfuzz from 0.1pt (the default value) to 0.5pt (this value is also used in \sloppy). Note that “overfull hbox” warnings are emitted only when the width is more than \hfuzz's value.
  • ranges.tex (L15112–15116, std.pdf: p. 1262+10): 141.33292pt too wide

    • The offending “word”: \tcode{… ? … : …}
    • Easily fixable. It is fixed by adding \brk after : .
  • iostreams.tex (L2279–2287 std.pdf: p. 1628+10): 21.81808pt too wide

    • The offending word: "implementation-defined" emitted from \impldef.
    • TeX does not hyphenate words that already contain hyphens (compound words). Adding \- changes this behavior. Compound words might be better not to be hyphenated, so I add \- conservatively (i.e. imple\-men\-ta\-tion-defined rather than im\-ple\-men\-ta\-tion-de\-fined).

The global macro \impldef is changed in the fix for the third case. This introduces changes like "implementation-\ndefined" -> "implementa-\ntion-defined" in other places.

@morinmorin
Copy link
Contributor Author

morinmorin commented Mar 26, 2023

A screenshot for the first case (iterator_-). The overfullness is very small (0.32013pt too wide).
iterator_category

@jensmaurer
Copy link
Member

For the first transgression, can you add a hyphenation hint iterator_catego-ry instead? Usually, the spaces are already very compressed when you get an overfull \hbox warning, and we regularly hyphenate this \tcode words if necessary.

@morinmorin
Copy link
Contributor Author

For the first transgression, the offending part is the - just after the highlighted "tor_" in the screenshot. \tcode{it\-er\-a\-tor_cat\-e\-go\-ry} doesn't make any change in the output.

The only viable hyphen-hint is \tcode{iterator\-_category}, which outputs "iterator-\n_category". Is this our preferred option?

@morinmorin
Copy link
Contributor Author

I took this route:

\tcode{iterator\-_category}

The issue is resolved now, I think.

@jensmaurer jensmaurer removed the changes requested Changes to the wording or approach have been requested and not yet applied. label Mar 29, 2023
@jensmaurer jensmaurer self-requested a review March 29, 2023 15:29
@jensmaurer
Copy link
Member

@tkoeppe, this looks like an editorial improvement.

@tkoeppe
Copy link
Contributor

tkoeppe commented Apr 30, 2023

@jensmaurer Yes, I agree. Any final thoughts?

Copy link
Member

@jensmaurer jensmaurer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tkoeppe, all good.

@tkoeppe tkoeppe merged commit 3e5125a into cplusplus:main May 10, 2023
2 checks passed
@morinmorin morinmorin deleted the fix_double_spacing branch May 10, 2023 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants