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

注册于 4年前

回答
194
文章
2
关注者
20

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}

需要自己计算在该点的法向量,但是 pgf 的计算精度不是很高,而且比较准确的数值算法会很慢。
image.png

\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usetikzlibrary{calc}
\usepgfplotslibrary{colormaps,fillbetween}

\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{(#3,#4,\@tempz)+\@tempu}}}%
  \?}
\makeatother

\begin{document}
\begin{tikzpicture}[declare function={f(\x,\y)=0.8*sin(deg(\x))+1.2*ln(\y);}]
\begin{axis}[axis equal image,view={-45}{15},
  domain=-2:5,y domain=0:5,samples=20,axis lines=center,axis on top,
  xmax=6,ymax=8,zmax=4,xmin=-2,ymin=-1,zmin=-2.5,
  xlabel=\tiny $X$,ylabel=\tiny $Y$,zlabel=\tiny $Z$]
\addplot3[colormap/bone,surf,z buffer=sort,] (x,y,{f(x,y)});
%%define P
\addplot3+ [mark=ball,mark size=2pt,scatter src=rand,ball color=yellow!80!black!60]
  coordinates {({0.25*pi},{3},{f(x,y)})};
\draw[->,shorten <=-1cm] ({0.25*pi},{3},{f(0.25*pi,3)}) 
  \pgfextra{\computegrad{f}{0.25*pi}{3}} -- \pgfmathresulta;

\draw[red,->,shorten <=-1cm] (0.785398, 3., 1.88402)--(1.35108, 3.4, 0.88402);
\end{axis}
\end{tikzpicture}
\end{document}

看看你的电脑上是否有这个文件夹:

c:\texlive\2024\texmf-dist\xindy\modules

可以保存切点和向量终点的坐标,然后利用 perpendicular 坐标系统即可画出。
ans-145-tikz.jpeg

\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{decorations.markings}

\makeatletter 
\def\my@tangentparse#1{\in@{ at}{#1}%
  \ifin@\my@tangentparse@#1\@nil\else\my@tangentparse@ last at#1\@nil\fi}
\def\my@tangentparse@#1 at#2\@nil{\pgfkeysalso{postaction=decorate,
  decoration = {    % 对path进行装饰(decorate)
    markings,    % 启用marking
    mark = at position #2    % 在指定位置#1添加marking
      with{    % marking的具体内容
        % 定义(0, 0)为tangent point xxx,即切点
        \coordinate (tangent point #1) at (0, 0);
        % 定义(1, 0)为tangent unit vector xxx,即单位切向量
        \coordinate (tangent unit vector #1) at (1, 0);
        % 定义(0, 1)为tangent orthogonal unit vector xxx,即单位法向量
        \coordinate (tangent orthogonal unit vector #1) at (0, 1);
      }
  },
}}
\tikzset{
  tangent/.code = \my@tangentparse{#1},
  use tangent/.style = {    % 定义use tangent样式,参数#1是切点的序号
    shift = (tangent point #1),     % 以tangent point-xxx为原点
    x = (tangent unit vector #1),    % 以tangent unit vector-xxx为x轴单位向量
    y = (tangent orthogonal unit vector #1)% 以tangent orthogonal unit vector-xxx为y轴单位向量
  },
  use tangent/.default = last,
}
\makeatother
\begin{document}
\begin{tikzpicture}
\draw[->] (-1,0) -- (3,0) node[anchor=south east]{$x$};
\draw[->] (0,-1) -- (0,2) node[anchor=south west]{$y$};
\draw[tangent=A at 0.65,tangent=B at 0.8] (0, 0) .. controls (1, 0) and (1, 1) .. (2, 0.5);
\fill[use tangent=A] circle(1pt) node[below=1] {$p$};
\draw[black!20,use tangent=A] (-1.5, 0) -- (1.5, 0);%切线
\draw[->, use tangent=A] (0, 0) -- (0, 1) coordinate(L) node[scale=0.4,above=2] {$vector$}; %法线

\draw[dotted,black!10, shorten <=-1cm] (L) -- (0,0 |- L); %辅助线
\draw[dotted,black!10] (L) -- (0,0 -| L); %辅助线

\draw[red,->] (tangent point A) -- (L |- tangent point A);
\draw[red,->] (tangent point A) -- (L -| tangent point A);

\draw[->, use tangent=B] (0, 0) -- (0, 1) coordinate(L);
\draw[red,->] (tangent point B) -- (L |- tangent point B);
\draw[red,->] (tangent point B) -- (L -| tangent point B);

\end{tikzpicture}
\end{document}

发布
问题