雾月
雾月
这家伙很懒,什么也没写!

注册于 4年前

回答
197
文章
2
关注者
21

你使用 \tableofcontents 然后查看 .toc 文件就能看到区别。可以再定义一个 expandable document cmd,放在 \section 里,再看看目录文件。

“展开”与上下文有关,需要区分“展开”和“执行”。“展开”是宏替换,把宏替换为其它东西。

在正常的上下文中,读入、展开、执行、输出这四个依次交替执行,这是一般情形。在所谓的“完全展开”的上下文中,比如 \expanded 的“参数”(也就是 latex3的 e 型展开),还有用 \write 把“参数”写入文件等等,这些参数都会被“展开”,但不会“执行”,“赋值”操作不会生效的。还有 f 型的展开,和 \csname \endcsname 之间的内容的展开。

与之相关的还有 protected 宏、robust 宏。前者不会在 e 型展开中被展开(但在正常的上下文中仍然会被展开)。后者是没有 protected 宏的时代为了阻止宏被展开的一个 trick。

interface3.pdf 中命令标有实心星号的可以在 e 型和 f 型中安全的展开,空心星号的可以在 e 型但不能在 f 型中安全的展开。

这些是下面要讲的内容的基础。

\NewDocumentCommand 定义的命令是 protected 宏,e 型展开不会展开它,所以写入文件时、做为 \expanded 的参数等情形,它都保持不变;而不是 protected 宏,比如 expandable document cmd,则会被替换为它的“替换文本”,这个替换是完全替换,也就是在此上下文中所有能被替换的都会替换,这种替换也就是“完全展开”。

要构造非得用 expandable document cmd 的情形,就比如在会展开而不会执行的上下文中,比如 \tl_set:Ne\str_set:Ne,然后用 \tl_show:N 查看它的值。你的例子只要把 \section 替换为 \tl_set:Ne 就好了。

另外,我们知道,latex3 除了有 int 类型,还有一种特殊的类型:flag,可以自己试试在 e 型展开中 \int_incr:N\flag_raise:N 有何区别。

TeXLive 2024 中,LaTeX3 有部分 API 名称发生了改变,exam-zh 应该是没有更新,可以在 https://gitee.com/xkwxdyy/exam-zh/issues/ 上提 issue。

第二种目录可以认为是一种特殊的索引,先分离出日期,然后分别按照标题和索引的方式处理就好了。可以做到像按字母分类一样按年月日分类。

cus 使用自己的方式制作标题和目录,不依赖也不兼容 etoc 和 titlesec,但是文档完整,样例基本可以直接复制使用。

https://github.com/Sophanatprime/cus 下载全部文件,并下载 https://github.com/Sophanatprime/lt3ekeys 中的所有 .sty 文件(或者把这些文件放在一个名为 lt3ekeys 的文件夹里,然后把这个文件夹(或者这些 .sty 文件)移动到 cus.sty 所属的文件夹下。

也可以直接克隆这两个 repo 到 TDS 目录里,然后执行 texhash 刷新数据库。

推荐后一种。

然后直接编译第一个链接里的 example 文件夹下的主文件。

有问题可以在对应 repo 里提 discussion 或 issue。

应该是 TeXLive/MacTeX 版本太低或与 ctex 不匹配。

一个随机的点可以由三个步骤生成:

  1. 由一个期望为 μ_x 的随机分布生成一个横坐标 x ;
  2. 根据 1 生成的横坐标,由一个随机分布生成一个纵坐标 y;
  3. 根据 1 生成的横坐标,由一个残差函数生成一个残差 r,

然后画出点 (x, y+r) 即可。不同的随机分布可以生成不同的图形。

比如类似图 A 的
image.png

\documentclass[tikz,border=5pt]{standalone}

\ExplSyntaxOn
\cs_new_protected:Npn \fpstepfromto#1#2#3 
  {% from, to, nums
    \fp_step_inline:nnnn {#1} { (#2-(#1))/(#3-1)*0.99 } {#2}
  }
\pgfmathdeclarefunction{nrand}{0}
  {% \tex_normaldeviate:D 生成均值为 0,标准差为 65536 的随机整数
    \tl_set:Nx \pgfmathresult { \fp_eval:n { \tex_normaldeviate:D/65536 } }
  }
\ExplSyntaxOff

\begin{document}

\begin{tikzpicture}
\draw[-stealth](0,0)--(3.5,0)node[below]{$x$};
\draw[-stealth](0,0)--(0,3.5)node[right]{$y$};

\pgfmathdeclarefunction{xx}{1}{\pgfmathparse{#1+nrand*#1/50}}
\pgfmathdeclarefunction{yy}{1}{\pgfmathparse{#1*4/5}} % y=4/5 x
\pgfmathdeclarefunction{res}{1}{\pgfmathparse{nrand/10}}
\fpstepfromto{0.5}{3}{10}{
  \pgfmathparse{xx(#1)}\let\xx\pgfmathresult
  \fill[black] (\xx,{yy(\xx)+res(\xx)}) circle(1pt);
}
\end{tikzpicture}

\end{document}

  1. 不知道你想要什么效果,我只是修复了代码中的错误,你可以自行编译查看是否符合需求。beautybook.cls
  2. MWE 是最小可工作示例,把全部文件打包进来显然不是“最小”。
  3. 类别码错误。在 .sty 文件中乱用 \mateatletter\makeatother,以及 LaTeX3 中空格会被忽略,但是 TikZ 中某些键需要用到空格。代码的问题就是这个造成的。
  4. 使用 .meta:nn 定义新的键,自行在我发的文件中查看实现方式。
  5. 代码不整洁,要合理缩进。

\noderotate 键。

\documentclass{beamer}
\usepackage{tikz}

\usebackgroundtemplate{\begin{tikzpicture}
  \draw[use as bounding box] (0,0) rectangle (\paperwidth,\paperheight);
  \node[inner sep=0pt,outer sep=0pt,rotate=3*\value{page}] at(.25\paperwidth,.75\paperheight) 
    {\pgfimage[width=0.5\paperwidth]{example-image}};
  \end{tikzpicture}}

\logo{\includegraphics[width=2cm, angle=\arabic{page}, origin=c]{example-image}}

\begin{document}

\frame{\arabic{page}}
\frame{\arabic{page}}
\frame{\arabic{page}}
\frame{\arabic{page}}
\frame{\arabic{page}}
\frame{\arabic{page}}
\frame{\arabic{page}}
\frame{\arabic{page}}

\end{document}

%%% autoclass.cls
\ProvidesClass{autoclass}

\DeclareKeys{% = \DeclareKeys[autoclass]
  lang .choice: ,
  lang/en .code:n = \def\autoclass@class{book} ,
  lang/cn .code:n = \def\autoclass@class{ctexbook} ,
  lang .initial:n = en ,
  unknown .code:n = \autoclass@unknown ,
}

\ExplSyntaxOn
\clist_new:N \autoclass@unknownoptions
\cs_new_protected:Npn \autoclass@unknown
  {
    \bool_if:NTF \l__keys_no_value_bool
      { % eg. 12pt, twoside
        \clist_put_right:Nx \autoclass@unknownoptions
          { \l_keys_key_str }
      }
      { % eg. zihao=4, fontset=windows
        \clist_put_right:Nx \autoclass@unknownoptions
          { \l_keys_key_str = { \exp_not:o \l_keys_value_tl } }
      }
  }
\ExplSyntaxOff

\ProcessKeyOptions % = \ProcessKeyOptions[autoclass]
\PassOptionsToClass\autoclass@unknownoptions\autoclass@class
%% 如果不需要过滤上面定义的 lang 等键,可以直接使用
%% \PassOptionsToClass\@raw@classoptionslist\autoclass@class

\LoadClass{\autoclass@class}
%%% main.tex
\documentclass[lang=cn,fontset=fandol,12pt]{autoclass}
\begin{document}

Hello.
\ifdefined\CTeX \CTeX 中文 \fi

\end{document}

在导言区加上这个:

\ExplSyntaxOn\makeatletter

\providecommand\Hy@footnote@currentHref{}
\prop_new:N\g__codedoc_fnmark_prop
\cs_new_protected:Npn \__codedoc_fn_store:
  {
    \prop_gput:Nxx\g__codedoc_fnmark_prop
      {fn\int_use:N\c@footnote}{{\Hy@footnote@currentHref}{\int_use:N\c@footnote}}
  }
\cs_new_protected:Npn \__codedoc_fn_restore:n  #1
  {
    \prop_get:NnN \g__codedoc_fnmark_prop {fn#1}\l__codedoc_tmpa_tl
    \tl_gset:Nx\Hy@footnote@currentHref
      {\exp_last_unbraced:NV\use_i:nn \l__codedoc_tmpa_tl }
    \setcounter{footnote}{\exp_last_unbraced:NV\use_ii:nn \l__codedoc_tmpa_tl}
  }
\cs_generate_variant:Nn \hook_gput_next_code:nn {ne}
\cs_new_protected:Npn \__codedoc_fn_footnote:nn #1 #2
  {
    \footnotemark
    \__codedoc_fn_store:
    \hook_gput_next_code:ne {env/#1/after}
      {\exp_not:N\__codedoc_fn_restore:n{\int_use:N\c@footnote}{\exp_not:n{\footnotetext{#2}}}}}

\AddToHook{env/function/begin}{\def\footnote{\__codedoc_fn_footnote:nn{function}}}
\AddToHook{env/variable/begin}{\def\footnote{\__codedoc_fn_footnote:nn{variable}}}

\makeatother\ExplSyntaxOff

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

\makeatletter
\ExplSyntaxOn
\cs_new:Npn \ifaivpaper@TF 
  { 
    \bool_lazy_and:nnTF 
      { \dim_compare_p:nNn { 297mm } = { \paperheight } } % 不能是 29.7cm
      { \dim_compare_p:nNn { 210mm } = { \paperwidth  } }
  }
\ExplSyntaxOff

\ifaivpaper@TF{a4paper}{not a4paper}

\makeatother

\end{document}

假定使用了 geometryfancyhdr 这两个宏包。

问题 1:脚注属于 total body(见 geometry.pdf 图 1、2)的一部分,footmisc 使用 bottom 的情况下,可使用 \usepackage[footskip=..]{geometry}(或 \geometry{footskip=..})修改脚注和页脚的间距。

2:页脚横线和页脚文字的间距可用 \pagestyle{fancy}...\renewcommand\footruleskip{..} 修改。

如果以上解决办法无效,需提供完整代码。

另外,每个提问都要提供完整可编译的代码

\documentclass{article}

\ExpandArgs{c}\NewDocumentCommand{cmd_1_a}{m O{}}{123 #1 #2}
\def\?#1 {\csname#1\endcsname}

\begin{document}

\?cmd_1_a {4}[6]

\end{document}

命令名完成后加上一个空格。还有不加空格的方法(使用 \peek_analysis_map_inline:n,不可展)。

应该用 \computegrad 的结果提取对应分量,你这个的模长不一样。
image.png

\documentclass[svgnames]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\makeatletter
\newcommand\computegrad[4][0.00025]{% [delta], function, x, y
    \begingroup\pgfkeys{/pgf/fpu,/pgf/fpu/output format=fixed}%
    \def\@tempdelta{#1}%
    \pgfmathparse{#2(#3,#4)}\let\@tempz\pgfmathresult
    \pgfmathparse{#2(#3+\@tempdelta,#4)}\let\@temppxa\pgfmathresult
    \pgfmathparse{#2(#3-\@tempdelta,#4)}\let\@temppxb\pgfmathresult
    \edef\@temppx{\fpeval{(\@temppxa-\@temppxb)/(2*\@tempdelta)}}%
    \pgfmathparse{#2(#3,#4+\@tempdelta)}\let\@temppya\pgfmathresult
    \pgfmathparse{#2(#3,#4-\@tempdelta)}\let\@temppyb\pgfmathresult
    \edef\@temppy{\fpeval{(\@temppya-\@temppyb)/(2*\@tempdelta)}}%
    \edef\@tempu{\fpeval{(\@temppx,\@temppy,-1)/sqrt(\@temppx^2+\@temppy^2+1)}}%
    \edef\?{\endgroup\def\noexpand\pgfmathresult{\@tempu}%
        \def\noexpand\pgfmathresulta{\fpeval{1*(#3,#4,\@tempz)-\@tempu}}}%
    \?}
\def\gradcomponent#1#2#3{%
  \edef\pgfmathresult{\fpeval{#2+\expanded{\noexpand\gradcomponent@#1}{#3}}}}
\def\gradcomponent@(#1,#2,#3)#4{\ifcase                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
    \if#4x 1 \else\if#4y 2 \else\if#4z 3 \else 4 \fi\fi\fi
  \or (0,#2,#3)\or (#1,0,#3)\or (#1,#2,0)\else(#1,#2,#3)\fi}
%%%%%%%%%%%%%%%%%green
\newcommand\computegraf[4][0.00025]{\computegrad[#1]{#2}{#3}{#4}}
%%%%%%%%%%%%%%%%%yellow
\newcommand\computegrag[4][0.00025]{\computegrad[#1]{#2}{#3}{#4}%
  \let\pgfmathresultb\pgfmathresult
  \gradcomponent\pgfmathresult\pgfmathresulta{y}%
  \let\pgfmathresulta\pgfmathresult \let\pgfmathresult\pgfmathresultb}
%%%%%%%%%%%%%%%%%red
\newcommand\computegrah[4][0.00025]{\computegrad[#1]{#2}{#3}{#4}%
  \let\pgfmathresultb\pgfmathresult
  \gradcomponent\pgfmathresult\pgfmathresulta{x}%
  \let\pgfmathresulta\pgfmathresult \let\pgfmathresult\pgfmathresultb}
%%%%%%%%%%%%%%%%%blue
\newcommand\computegral[4][0.00025]{\computegrad[#1]{#2}{#3}{#4}%
  \let\pgfmathresultb\pgfmathresult
  \gradcomponent\pgfmathresult\pgfmathresulta{z}%
  \let\pgfmathresulta\pgfmathresult \let\pgfmathresult\pgfmathresultb}
\makeatother    
\begin{tikzpicture}
[declare function={f(\x,\y)=0.6*sin(deg(\x))*cos(deg(\y);}]
\begin{axis}[scale=2,axis equal,view={0}{0},axis lines=center,axis on top,zmax=4.5,zmin=-1,samples=30,xlabel={$X$},ylabel={$Y$},zlabel={$F(x,y)$}]%ticks=none,
\addplot3[surf,color=DarkBlue,opacity=0.5,domain=0:2*pi, y domain=0:3,faceted color=black] {f(x,y)};
%%define P
\addplot3+ [mark=ball,mark size=2pt,scatter src=rand,ball color=yellow!80!black!60]
coordinates {({0.7},{0.25},{f(x,y)})};
\addplot3+ [mark=ball,mark size=2pt,scatter src=rand,ball color=yellow!80!black!60]
coordinates {({2.8},{0.5},{f(x,y)})};
%space vector
\draw[->,green,shorten <=0cm]({0.7},{0.25},{f(0.7,0.25)})\pgfextra{\computegraf{f}{0.7}{0.25}} --\pgfmathresulta;
%y vector
\draw[->,yellow,shorten <=0cm]({0.7},{0.25},{f(0.7,0.25)})\pgfextra{\computegrag{f}{0.7}{0.25}} --\pgfmathresulta;
%x vector
\draw[->,red,shorten <=0cm]({0.7},{0.25},{f(0.7,0.25)})\pgfextra{\computegrah{f}{0.7}{0.25}} --\pgfmathresulta;
%z vector
\draw[->,blue,shorten <=0cm]({0.7},{0.25},{f(0.7,0.25)})\pgfextra{\computegral{f}{0.7}{0.25}} --\pgfmathresulta;
%%%
%space vector
\draw[->,green,shorten <=0cm]({2.8},{0.5},{f(2.8,0.5)})\pgfextra{\computegraf{f}{2.8}{0.5}} --\pgfmathresulta;
%y vector
\draw[->,yellow,shorten <=0cm]({2.8},{0.5},{f(2.8,0.5)})\pgfextra{\computegrag{f}{2.8}{0.5}} --\pgfmathresulta;
%x vector
\draw[->,red,shorten <=0cm]({2.8},{0.5},{f(2.8,0.5)})\pgfextra{\computegrah{f}{2.8}{0.5}} --\pgfmathresulta;
%z vector
\draw[->,blue,shorten <=0cm]({2.8},{0.5},{f(2.8,0.5)})\pgfextra{\computegral{f}{2.8}{0.5}} --\pgfmathresulta;
\end{axis}
\end{tikzpicture}
\end{document}

发布
问题