鱼香肉丝没有鱼先生
鱼香肉丝没有鱼先生
鱼香肉丝没有鱼先生.

注册于 4年前

回答
106
文章
1
关注者
8

暂时没有找到原因, 可能需要读源码, 一种解决方案是

% 没有可选参数的 ceshi 环境
\begin{ceshi}[series = AAA]
    \item 这是一
    \item 这是二
    \item 这是三
\end{ceshi}

% 使用可选参数 resume 的 ceshi 环境
\begin{ceshi}[resume = AAA]
    \item 这
\end{ceshi}

补充一下答案,resume 失效的原因是

\begin{ceshi}
...
\end{ceshi}

加了一层 group,导致 resume 无法更新.

解决方案是

\NewDocumentEnvironment{ceshi}{O{} +b}{
  \enumerate[#1]
        #2
  \endenumerate
}{}

还需弥补丢失的 hook

\NewDocumentEnvironment{ceshi}{O{} +b}{%
  \UseHook{env/enumerate/before}%
  \UseHook{env/enumerate/begin}%
  \enumerate[#1]%
        #2
  \endenumerate%
  \UseHook{env/enumerate/end}%
  \UseHook{env/enumerate/after}%
}{}

关于第二点我做一个补充, 可以定义一个命令 \viewcoordinate 用于 Debug:

\makeatletter
\def\viewcoordinate(#1);{%
  \message{=================== Coordinate Debug Start ==================== ^^J^^J}
  \foreach \coor@dinate in {#1} {
    \path (\coor@dinate);
    \message{The coordinate `\coor@dinate' at (\the\pgf@x, \the\pgf@y)^^J^^J}
  }
  \message{=================== Coordinate Debug End ======================= ^^J^^J}
}
\makeatother

使用方法如下 \viewcoordinate(<coordinate comma list>);

\viewcoordinate(a, c, b, d);

mwe 如下

\documentclass{article}
\usepackage{tikz}

\usetikzlibrary{intersections}


\makeatletter
\def\viewcoordinate(#1);{%
  \message{=================== Coordinate Debug Start ==================== ^^J^^J}
  \foreach \coor@dinate in {#1} {
    \path (\coor@dinate);
    \message{The coordinate `\coor@dinate' at (\the\pgf@x, \the\pgf@y)^^J^^J}
  }
  \message{=================== Coordinate Debug End ======================= ^^J^^J}
}
\makeatother

\begin{document}

\begin{tikzpicture}
  % coordinate and node
  \coordinate (a) at (4,0);
  \coordinate (b) at (3.2,0);
  \coordinate (c) at (20pt,0);
  \node (d) at (2pt, 1cm) {d};
  \viewcoordinate(a, c, b, d);

  % intersections
  \draw[red, name path = circle] (0,0) circle (1cm);
  \draw[blue, name path = line] (-1.5, -.3) -- (2.3, 1.5);
  \path[name intersections = {of = circle and line, name = intersections}];

  \viewcoordinate(intersections-1, intersections-2);
\end{tikzpicture}

\end{document}

这会在你的日志文件中输出

=================== Coordinate Debug Start ==================== 

The coordinate `a' at (113.81097pt, 0.0pt)

The coordinate `c' at (20.0pt, 0.0pt)

The coordinate `b' at (91.04869pt, 0.0pt)

The coordinate `d' at (2.0pt, 28.45274pt)

=================== Coordinate Debug End ====================== 

=================== Coordinate Debug Start ==================== 

The coordinate `intersections-1' at (19.34659pt, 20.83994pt)

The coordinate `intersections-2' at (-28.39893pt, -1.7654pt)

=================== Coordinate Debug End ====================== 

参考 Tabularray with footnotes

\documentclass{article}
\usepackage[a4paper]{geometry}

\usepackage{tabularray}
\UseTblrLibrary{counter}
\UseTblrLibrary{functional}

\makeatletter
\IgnoreSpacesOn
\tlNew \gFootNoteTl
\intNew \gFootNoteInt
\prgNewFunction \footNote {m}
  {
    \tlPutRight \gFootNoteTl
      {
        \stepcounter{footnote}
        \footnotetext{#1}
      }
    \prgReturn {\footnotemark{}}
  }
\AddToHook{env/tblr/before}{
  \intSetEq \gFootNoteInt \c@footnote
  \tlClear \gFootNoteTl
}
\AddToHook{env/tblr/after}{
  \intSetEq \c@footnote \gFootNoteInt
  \tlUse \gFootNoteTl
}
\IgnoreSpacesOff
\makeatother

\begin{document}

Some note\footnote{some note} before.

\bigskip

\begin{tblr}[evaluate=\footNote]{colspec={ll},hlines}
a line & a text\footNote{with a note} in the middle\\
another line & another text\footNote{with another note} in the middle
\end{tblr}

\bigskip

\begin{tblr}[evaluate=\footNote]{colspec={ll},hlines}
a line & a text\footNote{with a note} in the middle\\
another line & another text\footNote{with another note} in the middle
\end{tblr}

\bigskip

Another note\footnote{another note} after.

\end{document}

image.png

需要使用

\usepackage{footnote}
\BeforeBeginEnvironment{tcolorbox}{\savenotes}
\AfterEndEnvironment{tcolorbox}{\endsavenotes}
\documentclass{book}

\usepackage{ctex}
\usepackage{tcolorbox}
\usepackage{footnote}
\BeforeBeginEnvironment{tcolorbox}{\savenotes}
\AfterEndEnvironment{tcolorbox}{\endsavenotes}
\begin{document}

浔阳江头夜送客,枫叶荻花秋瑟瑟footnote{注一}。
主人下马客在船,举酒欲饮无管弦。
醉不成欢惨将别,别时茫茫江浸月。

\begin{tcolorbox}

忽闻水上琵琶声,主人忘归客不发\footnote{注二}。
\end{tcolorbox}

\end{document}

image.png

% \usepackage{etoolbox}
\pretocmd\numberline{\hspace*{-1.5em}}{}{}

image.png

\fill 需要一条封闭路径

\fill[red!30,opacity=0.3] (0,0)-- plot[domain=0:1.25] ({tan(\x r)},\x)--(3, pi/2) -- (0, pi/2) -- cycle;
\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{amsmath}

\begin{document}


\begin{tikzpicture}[samples=1000,scale=1.5,xscale=1, yscale=1]
    
    \draw[thick,->] (-3.5,0) -- (3.5,0) node at(3.35,-0.2) {$x$};
    \draw[thick,->] (0,-2.5) -- (0,2.5) node at(0.2,2.3) {$y$};
    
    \draw[semithick,domain=-1.25:1.25]plot({tan(\x r)},\x);
    \draw[dashed](-3,pi/2)--(3,pi/2) (-3,-pi/2)--(3,-pi/2);
    
    \fill[red!30,opacity=0.3] (0,0)-- plot[domain=0:1.25] ({tan(\x r)},\x)--(3, pi/2) -- (0, pi/2) -- cycle;
\end{tikzpicture}
\end{document}

image.png

把我能优化的优化了一下

\documentclass[margin=1.5cm]{standalone}
\usepackage{ctex}
\usepackage{tikz}
\usetikzlibrary{shapes.symbols,positioning,calc}
\begin{document}
\begin{tikzpicture}[auto, rect/.style 2 args = {rectangle,rounded corners=1mm,fill=blue!30,draw=blue, minimum height = #1, minimum width = #2}]
    %\draw[help lines] (-5,-5) grid (5,5);
    \node[cloud,fill=gray!20,aspect=2] at (0,0) {\phantom{1234567890\\1234567890\\1234567890}};%
    \node[rect = {1.2cm}{0.5cm}, label = above:筛选器] (A) at (-2.5,.5) {A};
    \node[rect = {0.8cm}{1.0cm}, label = above:短时记忆] (B) at (-1,.5) {B};
    \node[rect = {1.0cm}{1.2cm}, label = left:工作记忆] (C) at (.5,-1) {C};
    \node[rect = {1.3cm}{1.5cm}, label = above:长时记忆] (D) at (2.3,.5) {D};

    \draw[<-, dashed] (A.west) -- ++(-3cm,0);
    \draw[<-, dashed, transform canvas = {yshift = .3cm}] (A.west) -- ++ (-3cm, 0);
    \draw[<-, dashed, transform canvas = {yshift = -.3cm}] (A.west) -- ++ (-3cm, 0);
    \draw[<-, dashed, transform canvas = {yshift = .2cm}] (B.west) --  (A.east);
    \draw[<-, dashed, transform canvas = {yshift = -.2cm}] (B.west) --  (A.east);

    \draw[->,dashed] (B.south east) -- (C.north west) node[midway,below left=-3pt] {3};
    \draw[<-,dashed] (C.north east)  -- (D.south west) node[midway,below right=-3pt] {4};
\end{tikzpicture}
\end{document}

优化代码的同时也要考虑代码的可读性,不要一味的追求短.

\documentclass{article}

\usepackage{amsmath, amssymb}

\usepackage[most]{tcolorbox}
\usepackage{tikz}
\usetikzlibrary{calc}
\makeatletter
\def\pgfgetnodeheight(#1)#2{
  \path ($(#1.south) - (#1.north)$);
  \pgfmathsetmacro#2{veclen(\pgf@x, \pgf@y)}
  \edef#2{#2pt}
}
\def\pgfgetnodewidth(#1)#2{
  \path ($(#1.east) - (#1.west)$);
  \pgfmathsetmacro#2{veclen(\pgf@x, \pgf@y)}
  \edef#2{#2pt}
}
\makeatother

\definecolor{tcbline}{RGB}{23, 139, 23}

\NewDocumentEnvironment{mybox}{O{}+b}{%
    \begin{tcolorbox}[
        breakable,
        enhanced,
        colbacktitle = white,
        coltitle = black,
        colback = white,
        colframe = tcbline,
        boxrule = 1pt,
        arc = 0pt,
        top = 2ex,
        attach boxed title to top left = 
        {
            xshift = 2em,
            yshift=-\tcboxedtitleheight/2,
            yshifttext=2mm-\tcboxedtitleheight/2
        },
        boxed title style = 
        {
            frame code = 
            {
                \pgfgetnodeheight(frame)\nHeight
                \pgfgetnodewidth(frame)\nWidth
                \draw[tcbline, thick] (frame.center) ellipse[x radius = \nWidth/2 - .1cm, y radius = \nHeight/2 + .1cm];
            },
            interior code = 
            {
                \pgfgetnodeheight(interior)\nHeight
                \pgfgetnodewidth(interior)\nWidth
                \fill[tcb fill interior] (interior.center) ellipse[x radius = \nWidth/2 - .07cm, y radius = \nHeight/2];
            }
        },
        #1
    ]
    #2
    \end{tcolorbox}
}{}


\begin{document}

\begin{mybox}[title = Example]
    \begin{center}
        Content
    \end{center}
\end{mybox}

\end{document}

image.png

试着做了一下

\documentclass{article}
\usepackage{lipsum}

\ExplSyntaxOn
\NewCommandCopy{\oldsection}{\section}

\keys_define:nn { alfred }
{
  date .clist_set:N = \l__alfred_date_tl,
  title .tl_set:N = \l__alfred_title_tl
}

\cs_new:Npn \alfred_parse_date:nN #1#2
{
  \tl_clear:N \l_tmpa_tl
  \clist_map_inline:nn { #1 }
  {
    \tl_put_right:Nn \l_tmpa_tl { ##1 }
  }
  \tl_set_eq:NN #2 \l_tmpa_tl 
}

\cs_new:Npn \alfred_parse_datefmt:nN #1#2 
{
  \tl_set:Ne \l_tmpa_tl 
  {
    \clist_item:nn {#1}{1}-
    \clist_item:nn {#1}{2}-
    \clist_item:nn {#1}{3}
  }
  \tl_set_eq:NN #2 \l_tmpa_tl 
}

\clist_new:N \g__alfred_date_clist 
\prop_new:N \g__alfred_section_date_title_prop
\tl_new:N \l__alfred_tmpa_tl 
\tl_new:N \l__alfred_tmpb_tl 
\tl_new:N \l__alfred_tmpc_tl 



\RenewDocumentCommand{\section}{sm}{
  \group_begin:
  \IfBooleanTF{#1}
  {
    \oldsection*{#2}
  }
  {
    \keys_set:nn { alfred } { #2 }
    \exp_args:NV \alfred_parse_date:nN \l__alfred_date_tl \l__alfred_tmpa_tl
    \exp_args:NV \alfred_parse_datefmt:nN \l__alfred_date_tl \l__alfred_tmpb_tl 
    \exp_args:No \oldsection { \l__alfred_tmpb_tl,~\l__alfred_title_tl }
    \clist_gput_right:NV \g__alfred_date_clist \l__alfred_tmpa_tl
    \prop_gput:NVx \g__alfred_section_date_title_prop \l__alfred_tmpa_tl 
    {
      \exp_not:N \contentsline{section}{\exp_not:N \numberline{\thesection} \l__alfred_tmpb_tl,~\l__alfred_title_tl}{\thepage}{}
    }
  }
  \group_end:
}

\iow_new:N \g__date_toc_iow

\AtEndDocument
{
  \clist_sort:Nn \g__alfred_date_clist
  {
    \int_compare:nNnTF { #1 } > { #2 }
    { \sort_return_swapped: }
    { \sort_return_same: }
  }
  \iow_open:Nn \g__date_toc_iow { \c_sys_jobname_str.date.toc }
  \clist_map_inline:Nn \g__alfred_date_clist 
  {
    \prop_get:NnN \g__alfred_section_date_title_prop { #1 } \l__alfred_tmpc_tl
    \exp_args:NNV \iow_now:Nn \g__date_toc_iow \l__alfred_tmpc_tl
  }
  \iow_close:N \g__date_toc_iow
}


\NewDocumentCommand{\tableofcontentswithdate}{}
{
  \section*{Contents~With~Date}
  \makeatletter
  \file_if_exist_input:n { \c_sys_jobname_str.date.toc }
  \makeatother
  \vspace*{.5in}
}
\ExplSyntaxOff

\begin{document}

\tableofcontents

\tableofcontentswithdate





\section{title = first, date = {2024, 09, 19}}

\lipsum[1-10]

\section{title = second, date = {2023, 06, 05}}

\lipsum[1-10]

\section{title = third, date = {2024, 08, 10}}

\lipsum[1-10]


\end{document}

image.png

答案就是 unicode-mathbegin/document 添加了 hook, 并重定义了 \vec, 想要验证并不难

\documentclass{minimal}
\usepackage{unicode-math}
\expandafter\def\expandafter\cmd\expandafter{\meaning\vec}
\begin{document}

\fbox{Before document} \cmd

\fbox{After document} \meaning\vec

\end{document}

image.png

所以, 你要么换个命令名, 要么也 hook 一下.

这个问题不好回答,我更倾向于你需要这个 绝对位置 之后想要干什么?

我对 tikz 不太熟悉, 不确定是否有现成的方案来处理这个问题, 我自己造了个轮子

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}

\makeatletter
\def\pgfgetnodeheight(#1)#2{
  \path ($(#1.south) - (#1.north)$);
  \pgfmathsetmacro#2{veclen(\pgf@x, \pgf@y)}
  \edef#2{#2pt}
}
\def\pgfgetnodewidth(#1)#2{
  \path ($(#1.east) - (#1.west)$);
  \pgfmathsetmacro#2{veclen(\pgf@x, \pgf@y)}
  \edef#2{#2pt}
}
\makeatother

\begin{tikzpicture}
  \node[anchor = south west, draw, align = left] (a) {text width \\ text width};
  \pgfgetnodewidth(a)\nWidth
  \pgfgetnodeheight(a)\nHeight
  \draw[red] (0, -.1) -- (\nWidth, -.1) node[midway, below, text = black] {\nWidth};;
  \draw[blue] (-.1, 0) -- (-.1, \nHeight) node[midway, left, text = black] {\nHeight};
\end{tikzpicture}
\end{document}

image.png

  1. 我不知道你是否对 \seq_set_split:xx 函数有点误解?

它用于对一段 token 按某特定 token 进行分割, 同时会删掉两边的空格.
例如

\ExplSyntaxOn
  \seq_set_split:Nnn \l_tmpa_seq { \sep } {a \sep b \sep c}
  \seq_log:N \l_tmpa_seq
\ExplSyntaxOff

.log 中会有

The sequence \l_tmpa_seq contains the items (without outer braces):
>  {a}
>  {b}
>  {c}.

同理, 你的

\ExplSyntaxOn
  \seq_set_split:Nnn \l_tmpa_seq { tk } {tk 这是选择题 1 答案}
  \seq_log:N \l_tmpa_seq
\ExplSyntaxOff

会得到

The sequence \l_tmpa_seq contains the items (without outer braces):
>  {}
>  {这是选择题1答案}.

注意, 有两项.

  1. enumerate 中无法显示,其实和 enumerate 无关,你可以尝试
\begingroup 
  测试\par
  \fourchoices{这是选择题1答案}
  测试\par
  \fourchoices{这是选择题2答案}
  测试\par
  \fourchoices{这是选择题3答案}
  测试\par
  \fourchoices{这是选择题4答案}
  测试\par
  \fillin{这是填空题1答案}
  测试\par
  \fillin{这是填空题2答案}
  测试\par
  \fillin{这是填空题3答案}
  测试\par
  \fourchoices{这是选择题8答案}
  测试\par
  \jieda{这是解答题1答案}
  测试\par
  \jieda{这是解答题2答案}
  测试\par
  \jieda{这是解答题3答案}        
  测试\par
  \fourchoices{这是选择题12答案}
\endgroup

也是无法显示, 这个就留给你自己思考吧!

x 型展开是递归展开至不可展开为止, f 型展开类似于 x 型展开,但是它会在展开至(遇到)第一个不可展开的 token 时停止.

这里你不应该使用 \tl_use:N 因为它会直接显示该 token 的值.

你可以使用 \cs_meaning:N 或者 \tl_log:N 等函数.

\ExplSyntaxOn
\tl_set:Nn \l_mya_tl { A }
\tl_set:Nn \l_myb_tl { B }
\tl_set:Nx \l_mya_tl { text1 \l_mya_tl text2 \l_myb_tl text3 }
\tl_log:N \l_mya_tl \par

\tl_set:Nn \l_myc_tl { C }
\tl_set:Nn \l_myd_tl { D }
% \tl_set:Nf \l_myc_tl { text\l_myc_tltext\l_myd_tl} % error
\tl_set:Nf \l_myc_tl { \l_myc_tl text\l_myd_tl } 
% 体现不出来区别,也不是很明白什么叫<space token>
\tl_log:N \l_myc_tl \par
\ExplSyntaxOff

在日志中可看到

> \l_mya_tl=text1Atext2Btext3.
> \l_myc_tl=Ctext\l_myd_tl .

是的, 当你使用 \int_new:N 时系统会为你分配一个整数寄存器, 而你的 \l_test_int 只是它的别名? 过程类似于?

\newcount\count291
\let\l_test_int=\count291

你要调试它的值可以使用

\int_show:N \l_test_int
\int_log:N \l_test_int

将会得到

> \l_test_int=5.

发布
问题