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

\peek_analysis_map_inline:n does not work in tabular environment #1090

Closed
jlaurens opened this issue May 5, 2022 · 2 comments
Closed

\peek_analysis_map_inline:n does not work in tabular environment #1090

jlaurens opened this issue May 5, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@jlaurens
Copy link
Contributor

jlaurens commented May 5, 2022

The effect of the \TEST command is to gobble the next token.
Of course, a real life use would not break the analysis so early.

\documentclass{minimal}
\begin{document}
\ExplSyntaxOn
\def \TEST {
  \peek_analysis_map_inline:n {
    \peek_analysis_map_break:
  }
}
\ExplSyntaxOff
\TEST XYZ
\begin{tabular}{c}
\TEST XYZ
\end{tabular}
\end{document}

Things unexpectedly break on the second \TEST call with error

! Argument of \__tl_tmp:w has an extra }.
<inserted text> 
\par 
l.12 \TEST X
          YZ
? 
@user202729
Copy link
Contributor

As a workaround:

\protected\def \TEST {
  \group_align_safe_begin:
  \peek_analysis_map_inline:n {
    \peek_analysis_map_break:n {\group_align_safe_end:}
  }
}

I didn't analyze whether peek_analysis can do that on its own.

@PhelypeOleinik
Copy link
Member

PhelypeOleinik commented May 14, 2022

The fix, I think, is in the same line as user202829's. Just adding \group_align_safe_begin/end:

\ExplSyntaxOn
\cs_gset_protected:Npn \peek_analysis_map_inline:n #1
  {
    \group_align_safe_begin: % <-- added
    \int_gincr:N \g__kernel_prg_map_int
    \cs_set_protected:cpn
      { __tl_analysis_map_ \int_use:N \g__kernel_prg_map_int :nnN }
      ##1##2##3
      {
        \group_end:
        #1
        \__tl_peek_analysis_loop:NNn
          \prg_break_point:Nn \peek_analysis_map_break: { \group_align_safe_end: } % <-- added
      }
    \__tl_peek_analysis_loop:NNn ? ? ?
  }
\ExplSyntaxOff

@PhelypeOleinik PhelypeOleinik added the bug Something isn't working label Jun 15, 2022
abstrnoah added a commit to abstrnoah/brumaltex that referenced this issue Jan 15, 2024
See <latex3/latex3#1090>.
The issue manifests here when placing formatted objects inside
environments like gather or align. The issue seems to have been fixed in
the latest version of latex3 but tectonic doesn't ship it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants