Git Product home page Git Product logo

Comments (8)

xkwxdyy avatar xkwxdyy commented on August 29, 2024

测试期间发现了一个警告

Package hyperref: Token not allowed in a PDF string (Unicode):
(hyperref)	removing `\__whu_use_constant:nn'.

猜测会不会是展开的太晚了?

from cus.

Sophanatprime avatar Sophanatprime commented on August 29, 2024

在写入目录文件、标签、书签等时,\protected 的宏不会被展开。\__whu_use_constant:nn 不能定义成 \protected
而且在读入目录文件时,不会开启 LaTeX3 语法环境,所以展开之后的内容不能有以 LaTeX3 命名规范命名(包含 _ : 等)的命令。

from cus.

xkwxdyy avatar xkwxdyy commented on August 29, 2024

在写入目录文件、标签、书签等时,\protected 的宏不会被展开。\__whu_use_constant:nn 不能定义成 \protected

原来如此,感谢提醒。

而且在读入目录文件时,不会开启 LaTeX3 语法环境,所以展开之后的内容不能有以 LaTeX3 命名规范命名(包含 _ : 等)的命令。

请问我这个需求怎么办,能用别的方式解决吗?

from cus.

xkwxdyy avatar xkwxdyy commented on August 29, 2024

或者把 _ 换成 @

from cus.

Sophanatprime avatar Sophanatprime commented on August 29, 2024

请问我这个需求怎么办,能用别的方式解决吗?

\tl_use:N 是可展的,用 \cs_new:Npn \__whu_use_constant:nn 就可以了,写入目录文件时它会自己展开。

from cus.

xkwxdyy avatar xkwxdyy commented on August 29, 2024

\tl_use:N 是可展的,用 \cs_new:Npn \__whu_use_constant:nn 就可以了,写入目录文件时它会自己展开。

我可能没表述清楚,我看到您这句话

而且在读入目录文件时,不会开启 LaTeX3 语法环境,所以展开之后的内容不能有以 LaTeX3 命名规范命名(包含 _ ``: 等)的命令。

的时候,我以为是除了 protected 的另外一个问题,我以为除了改成 \cs_new:Npn \__whu_use_constant:nn外 展开的内容里面不能出现 _, 所以我本来打算把 c__whu_constant_ #1/#2 _tl 改成 c@@whu@constant@ #1/#2 @tl 的。

但测试下来改成 \cs_new:Npn \__whu_use_constant:nn 之后 c__whu_constant_ #1/#2 _tlc@@whu@constant@ #1/#2 @tl 都可以行得通,但是 c__whu_constant_ #1/#2 _tl 里面不是也有 _ 吗?这和您上面那个

不能有以 LaTeX3 命名规范命名(包含 _ ``: 等)的命令。

之间好像不太一样?(抱歉,我有点不太懂太深的展开原理)

from cus.

Sophanatprime avatar Sophanatprime commented on August 29, 2024

一个命令能否展开、会不会展开、怎么展开和它所处的上下文有关。
interface3.pdf 里标记 ⋆ 的是可以用于 ef 参数,标记 ✩ 可以用于 e 参数,用在这些参数中它们被完全展开。
写入目录文件、标签、书签等,和用在 e 参数中类似,不过用 \DeclareRobustCommand 定义的命令也不会展开,所以 \textbf 这些可以安全的写入目录文件。

\protected 命令不会在 e 参数中展开,但出现在控制序列的名称中会展开(所以 \__whu_get_constant_csname:nn 能生效)。
所以使用 \cs_new:Npn \__whu_use_constant:nn 会在 e 参数中展开为 \tl_use:c { c__whu_constant_ #1/#2 _tl }\tl_use:c 还可以展开,但它先把后面那个变成一个控制序列,变成了 \tl_use:N <...>\tl_use:N 还可以展开,它的作用是展开为那个 tl 的内容,而这个 tl 的内容并没有 LaTeX3 名称的命令,所以能够正确读取。

from cus.

xkwxdyy avatar xkwxdyy commented on August 29, 2024

一个命令能否展开、会不会展开、怎么展开和它所处的上下文有关。 interface3.pdf 里标记 ⋆ 的是可以用于 ef 参数,标记 ✩ 可以用于 e 参数,用在这些参数中它们被完全展开。 写入目录文件、标签、书签等,和用在 e 参数中类似,不过用 \DeclareRobustCommand 定义的命令也不会展开,所以 \textbf 这些可以安全的写入目录文件。

\protected 命令不会在 e 参数中展开,但出现在控制序列的名称中会展开(所以 \__whu_get_constant_csname:nn 能生效)。 所以使用 \cs_new:Npn \__whu_use_constant:nn 会在 e 参数中展开为 \tl_use:c { c__whu_constant_ #1/#2 _tl }\tl_use:c 还可以展开,但它先把后面那个变成一个控制序列,变成了 \tl_use:N <...>\tl_use:N 还可以展开,它的作用是展开为那个 tl 的内容,而这个 tl 的内容并没有 LaTeX3 名称的命令,所以能够正确读取。

非常感谢!

from cus.

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.