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

注册于 4年前

回答
219
文章
2
关注者
23

%%% 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}

在导言区加上 \usefonttheme{professionalfonts}。可以放在 \usepackage{mtpro2} 前一行。

如果没有递增计数器,\ref 显示为空,hyperref 不会为空的文本创建超链接。
只能使用 \hyperref[<label>]{<text>}\pageref

也可以在写入 \label 时就指定需要显示的文字:

\documentclass{article}

\usepackage{tcolorbox}
\usepackage{hyperref}


\tcbuselibrary{skins,minted}

%% 重定义minted环境前的行号样式
\renewcommand{\theFancyVerbLine}
{%
  \ttfamily\textcolor[rgb]{0.5,0.5,1.0}
  {%
    \footnotesize\arabic{FancyVerbLine}
  }
}

\makeatletter
\protected\def\setnextlabeltext#1{\AddToHookNext{label}{\protected@edef\@currentlabel{#1}%
  \edef\@currentlabel{\detokenize\expandafter{\@currentlabel}}}}
\makeatother
\newcounter{myexample}
\NewTCBListing{myjava}{O{} O{}}{%
    listing engine  = minted,
    minted style    = colorful,
    minted language = java,
    %minted label =#1
    minted options={%
        fontsize = \small,
        breaklines,
        autogobble,
        linenos,
        numbersep = -1.5mm,
        %numbersep   = 3pt,
        keywordcase = lower, % 关键字小写, upper为大写, capitalize为首字母大写, 默认为lower
        mathescape  = true,  % 在注释中可以书写并渲染数学公式
        showspaces  = false,
        tabsize     = 4,
        texcomments = false,
        %framerule   = 1pt,
        %breaklines  = true,
        fontfamily  = tt,
    },
    %colback  = blue!5!white,
    %colframe = blue!75!black,
    colback  = white,
    colframe = black,
    colbacktitle=white,
    coltitle=black,
    listing only,
    left = 5mm,
    enhanced,
    overlay = {\begin{tcbclipinterior}\fill[red!20!blue!20!white] (frame.south west)
    rectangle ([xshift = 5mm]frame.north west);\end{tcbclipinterior}},
    attach boxed title to top center = {yshift =-3mm},
    center title,
    %IfValueTF = {#1}{title=#1}{step=myexample, title=code:\themyexample},
    IfEmptyTF = {#1}{% 第一个没有值
      step=myexample, title=code:\themyexample, 
      IfEmptyTF={#2}{label=code:\themyexample}{label={#2}}
    }{% 第一个有值
      title={#1}, IfEmptyTF={#2}{}{phantom=\setnextlabeltext{#1},phantomlabel={#2}}
    },
    fonttitle = \ttfamily\large,
    boxrule=0.75pt,
    boxed title style={
        boxrule=0pt,
        colframe=white,
        size = fbox,
    },
    %frame hidden
    %boxed title style={arc=0pt,outer arc=0pt,boxrule=0pt}, 
}

\begin{document}

\begin{myjava}[test][aaa]
    public class HelloWorld {
        // A `Hello World' in Java
        public static void main(String[] args) {
        System.out.println("Hello World!");
    }
    }
\end{myjava}

\begin{myjava}
    public class HelloWorld {
        // A `Hello World' in Java
        public static void main(String[] args) {
        System.out.println("Hello World!");
    }
    }
\end{myjava}

a\hyperref[aaa]{text}.\pageref{aaa}.\ref{aaa}.\ref{code:1}.

\end{document}

这个 \setnextlabeltext 也可以在递增计数器之后,\label 之前使用。

microtype 的多数功能只是对 primitive 的封装,XeTeX 缺少对应的 primitive,很多功能没法实现。

某些功能有替代办法,比如 \textls 可以通过设置 fontspec 的选项 WordSpaceLetterSpace 为合适的值来替代。

\documentclass{..}
\usepackage{morewrites}
...

\RequirePackage{morewrites}
\documentclass{..}

morewrites 要放在很前面才能有效。

这是右边页码宽度增加了,但是 logo 和页码的距离不变,所以 logo 往左移了一点。
如果使用 fancyhdrtitleps等,应该对左、中、右的页眉分别设置,而不是设置一个固定长度。

发布
问题