Sagittarius Rover
Sagittarius Rover
这家伙很懒,什么也没写!

注册于 3年前

回答
464
文章
0
关注者
15

我没有细看文档,但似乎「\SetArgSty」可以修改这里的样式

\SetArgSty{<font>} sets the argument typography (by default: emph).
\documentclass[fontset=fandol]{ctexart}
\usepackage{graphicx} % Required for inserting images
\usepackage[ruled,vlined,linesnumbered]{algorithm2e}
\usepackage{amsmath,amsfonts}

\begin{document}
\SetArgSty{textup}%
\section{Introduction}

\begin{algorithm}[H]
    \SetAlgoLined
    \KwData{this text}
    \KwResult{how to write algorithm with \LaTeX2e}
    \While{not at end of this document}{
        read current\; 
        \eIf{understand}{
        go to next section\;
        current section becomes this one\;
        }{
        go back to the beginning of current section\;
        }
    }
\end{algorithm}

\begin{algorithm}[htb]
    \SetAlgoLined
    \KwResult{每个时间步的参数$\theta$}
        \For{第$1,2,\dots,n$个时间步}{
        对上一步的态$|\psi(\theta_t) \rangle$作用时间演化算子$e^{-iH\Delta t}$,得参照态$e^{-iH\Delta t}|\psi(\theta_t) \rangle$ \;
        初始化$\theta = \theta_t$ \;
        求惩罚函数的梯度$\nabla_{\theta}C(\theta)$ \;
        \While{$|\nabla_{\theta}C(\theta)| > \text{grad}_{\text{tol}}$ 且 $\text{count} < \text{count}_{\text{max}}$}{
        根据梯度$\nabla_{\theta}C(\theta)$,利用ADAM优化器更新参数$\theta$ \;
        $\text{count}$加1 \;
        求惩罚函数的梯度$\nabla_{\theta}C(\theta)$ \;
        }
    }  
\end{algorithm}

\end{document}

嗯...因为我懒得读完全部文档...所以未必是好的实践...

注意到elegantbook.cls中对proof的定义,修改一下即可.

% Line 1192~1196
\newenvironment{proof}{
  \par\noindent\textbf{\color{second}\proofname\;}
  \color{black!90}\cfs}{
  % \hfill$\Box$\quad
  \par}

其实手动指定硬编码数字「2」也是不够好的...

\documentclass[lang=cn]{elegantbook}
\usepackage{zhlipsum}%
\renewenvironment{proof}[1][]{%
  \par\noindent\textbf{\color{second}\proofname\;#1\;}
  \color{black!90}\cfs}{
  % \hfill$\Box$\quad
  \par}%
\begin{document}

\begin{proof}
    显然。
\end{proof}

\begin{proof}[(2)]
    显然。这是一个证明:\zhlipsum[2]
\end{proof}

\begin{proof}[「5」]
    显然。这是另一个证明:\zhlipsum[2]
\end{proof}

\end{document}

image.png

补充一些信息...

需要注意到在elegantbook.cls中的definition环境的定义为:

% Line 1079
\ELEGANT@newtheorem{definition}{defstyle}
% Line 902
  \tcbset{
    common/.style={
      fontupper=\citshape,
      lower separated=false,
      % before upper={\setlength{\parindent}{\normalparindent}},
      coltitle=white,
      colback=gray!5,
      boxrule=0.5pt,
      fonttitle=\bfseries,
      enhanced,
      breakable,
      top=8pt,
      before skip=8pt,
      attach boxed title to top left={
        yshift=-0.11in,
        xshift=0.15in},
      boxed title style={
        boxrule=0pt,
        colframe=white,
        arc=0pt,
        outer arc=0pt},
      separator sign={.},},
    defstyle/.style={
      common,
      colframe=main,  
      colback=main!5,
      colbacktitle=main, 
      overlay unbroken and last={
        \node[anchor=south east, outer sep=0pt] at (\linewidth-width,0) {
          \textcolor{main}{$\clubsuit$}};}},
          ...

其中fontupper=\citshape使用的定义为:

\ifcsname kaishu\endcsname
 \newcommand{\citshape}{\kaishu}
\else
 \newcommand{\citshape}{\itshape}
\fi

所以要想在定义环境里加粗,需要保证「楷体」有粗体的字重,或者使用伪粗体...

  • 在windows系统下默认fontset=windows,将默认使用「中易楷体」(a.k.a. simkai.ttf),没有粗体字重
  • 在texpage/overleaf/ubuntu下默认为fontset=fandol,默认使用「fandol-kai」同样没有粗体字重
  • 使用fontset=ubuntu使用的是思源字库(win下需要自行安装),其对应使用的楷体为「gkai00mp.ttf」(似乎是文鼎楷体),同样没有粗体的字重
  • 啸行老师上面的回答里使用了「方正楷体」(可以使用fontset=founder),其楷体字形是有粗体的,因此表现正常

P.S.一个 不推荐 的方式是使用「伪粗体」,如下在windows的例子:

\documentclass[lang=cn]{elegantbook}
\setCJKfamilyfont{zhkai}[AutoFakeBold]{simkai.ttf}
\renewcommand*{\kaishu}{\CJKfamily{zhkai}}
\begin{document}

\begin{definition}
    你好,我想要在这里\textbf{加粗}哈哈哈
    
    我在windows下用的是「中易楷体」,没有粗体
\end{definition}

\end{document}

image.png

Edited

其实也可以改一下让定义环境里不使用楷体,而是使用常见的宋体.作为示例:

\documentclass[lang=cn]{elegantbook}
\tcbset{common/.append style={fontupper=\normalfont}}
\begin{document}

\begin{definition}
    你好,我想要在这里\textbf{加粗}哈哈哈
    
    我现在在windows下用的是「中易宋体」,没有粗体,所以改用「中易黑体」做为粗体
\end{definition}

\end{document}

image.png

或者使用fandol-song

\documentclass[lang=cn,fontset=fandol]{elegantbook}
\tcbset{common/.append style={fontupper=\normalfont}}
\begin{document}

\begin{definition}
    你好,我想要在这里\textbf{加粗}哈哈哈
    
    我现在在windows下用的是「fandol宋体」,他有粗体
\end{definition}

\end{document}

image.png

核心原因还是因为elegant-latexcommon这个style使用了楷体,但是有粗字重的楷体太少了...

该问题的最小工作示例其实可以更短:

\documentclass[AutoFakeBold]{ctexart}
\setmainfont{Times New Roman}
\begin{document}
{\zihao{-2}\songti\bfseries%

1. 问题复现

1.1 问题描述

1.1.1 问题背景

2. 工作人员

2.1 工作人员

2.1.1 工作人员

}
\end{document}

总结一下上面的测试结果:

  • windows: simsum.ttcTime New Roman的基线比较匹配
  • macOS: STsong.ttfTime New Roman的基线不匹配
  • ubuntu: fandol-song.ttfTime New Roman的基线不匹配

至于怎么办嘛,看格式要求

如果格式要求就是: 宋体+TNR,最好使用中易宋体

否则可以考虑替换西文字体,并不是任意两个西文字体和中文字体都是那么匹配的...

2025年,可以不用cleveref而改用zref-clever:

\documentclass{beamer}
\usepackage{hyperref}
% \usepackage{cleveref}
% \crefformat{equation}{\mbox{Eq. #2(#1)#3}}
% \crefrangeformat{equation}{\mbox{Eqs. #3(#1)#4 to #5(#2)#6}}
% \crefmultiformat{equation}{\mbox{Eqs. #2(#1)#3}}{ and #2(#1)#3}{, #2(#1)#3}{ and #2(#1)#3}
% \crefrangemultiformat{equation}{\mbox{Eqs. #3(#1)#4 to #5(#2)#6}}{ and #3(#1)#4 to #5(#2)#6}{, #3(#1)#4 to #5(#2)#6}{ and #3(#1)#4 to #5(#2)#6}

\usepackage{zref-clever}
\zcRefTypeSetup{equation}{
    name-sg={eq.},
    name-pl={eqs.},
    Name-sg={Eq.},
    Name-pl={Eqs.},
}

\begin{document}

\begin{frame}{Title Here}

    \begin{block}

        \begin{align}
            A  &= B
            \label{eq1}
            \\
             &= C
             \label{eq2}
             \\
             &= D
             \label{eq3}
        \end{align}

    \end{block}

\end{frame}


\begin{frame}{Title Here}

    \begin{block}

        \begin{align}
            A  &= B
            \label{eq4}
            \\
             &= C
             \label{eq5}
             \\
             &= D
             \label{eq6}
        \end{align}

    \end{block}

\end{frame}

\begin{frame}{Title Here}

\begin{block}

    \begin{align}
    A  &= B
    \label{eq7}
    \\
    &= C
    \label{eq8}
    \\
    &= D
    \label{eq9}
    \end{align}

\end{block}

\end{frame}

\begin{frame}
    contents in between
\end{frame}


\begin{frame}

    % \cref{eq1} 

    % \cref{eq1,,eq2}

    % \cref{eq1,eq2,eq3} 

    % \cref{eq1,eq2,eq3,eq7,eq8,eq9} 

    % \cref{eq1,,eq2,,eq3,eq7,eq8,eq9} 

    % \cref{eq6,eq7,eq9} 

    % Eq. \ref{eq1} 
   

    \zcref[S]{eq1} 

    \zcref[S]{eq1,,eq2}

    \zcref[S]{eq1,eq2,eq3} 

    \zcref[S]{eq1,eq2,eq3,eq7,eq8,eq9} 

    \zcref[S]{eq1,,eq2,,eq3,eq7,eq8,eq9} % I want "Eqs. (1),(2),(3) and (7) to (9)"

    \zcref[S]{eq6,eq7,eq9} 

    Eq. \zref{eq1} 
\end{frame}

\end{document}

这样不会报任何警告,虽然「编号形式受到\seq_set_from_clist:Nnclist的解析小问题」,但是很少会用到\cref{eq1,,eq2,,eq3,eq7,eq8,eq9}这样故意空格的需求...

image.png

有些重叠的区域填充两种不同的颜色,会互相遮挡和影响。

从你的第二张图来看,这种遮挡似乎不影响你看图、识别三角形和做题.

如果三角形AMB和三角形QME用合适的阴影方式来填充的话,怎么处理为宜。

我想着主要填充的区域用颜色;次要或者小点的填充区域用阴影,就是哪种相对稀疏的斜杠线阴影。但一直操作不成功。

在tikz中可以使用patterns库,详见这个链接. 事实上你已经调用了,但不知为何你没有去查阅这部分的文档.

\documentclass[tikz,border=5pt]{standalone}
\usepackage{tkz-base}
\usepackage{tkz-euclide}
\usetikzlibrary{patterns,patterns.meta}
\begin{document}
\begin{tikzpicture}
        % ===== 1. 绘制平面直角坐标系 =====
        \tkzInit[xmin=-2.5, xmax=4.5, ymin=-1, ymax=6.3]
        \tkzDrawXY[thick, noticks, >=latex]
        
        % ===== 定义点 =====
        \tkzDefPoints{0/0/O, 0/4/A, 2/0/B, 0/2/E}
        
        \tkzDefTriangle[two angles=90 and 45](A,B)
        \tkzGetPoint{C}
        
        \tkzDefPointBy[projection=onto O--B](C)
        \tkzGetPoint{c}
        
        \tkzDefPointBy[projection=onto C--c](E)
        \tkzGetPoint{e}
        
        \tkzInterLL(C,c)(E,e)
        \tkzGetPoint{D}
        
        \tkzDefMidPoint(E,B)
        \tkzGetPoint{M}
        
        \tkzInterLL(D,M)(O,B)
        \tkzGetPoint{Q}
        
        \tkzCalcLength(A,M)
        \tkzGetLength{dAM}
        
        \tkzDefPointWith[linear normed,K=-\dAM](M,A)
        \tkzGetPoint{Q}
        
        \tkzInterLL(E,D)(A,B)
        \tkzGetPoint{N}


        \tkzFillPolygon[yellow!50, opacity=.5](A,D,C)
        \tkzFillPolygon[yellow!50, opacity=.5](E,Q,D)
        
        \tkzFillPolygon[pattern=north east lines, pattern color=teal](E,Q,M)
        \tkzFillPolygon[pattern={Stars[points=6]},pattern color=magenta](A,B,M)
        
        % ===== 绘制图形 =====
        \tkzDrawSegments[thick](E,B A,M D,M) 
        \tkzDrawPolygon[red, thick](A,B,C)
        \tkzDrawPolygon[blue, thick](E,C,D)
        
        \tkzDrawSegments[dashed, purple!50, thick](Q,M A,D D,Q E,Q) 
        
        % ===== 标示点 =====
        \tkzLabelPoints[above right](C,N)
        \tkzLabelPoints[left](A,E)
        \tkzLabelPoints[right](D)
        \tkzLabelPoints[below](B,Q)
        \tkzLabelPoints[below left](O,M)
    \end{tikzpicture}
\end{document}

image.png

注意最好把:

        \tkzFillPolygon[yellow!50, opacity=.5](A,D,C)
        \tkzFillPolygon[yellow!50, opacity=.5](E,Q,D)
        \tkzFillPolygon[pattern=north east lines, pattern color=teal](E,Q,M)
        \tkzFillPolygon[pattern={Stars[points=6]},pattern color=magenta](A,B,M)

放到:

        % ===== 绘制图形 =====
        \tkzDrawSegments[thick](E,B A,M D,M) 
        \tkzDrawPolygon[red, thick](A,B,C)
        \tkzDrawPolygon[blue, thick](E,C,D)
        \tkzDrawSegments[dashed, purple!50, thick](Q,M A,D D,Q E,Q) 

之前,避免不正确的绘制顺序带来的遮挡。

\documentclass{article}
\usepackage[tt=false]{libertine}
\usepackage{framed}
\usepackage{lipsum}
\newcounter{question}
\newcounter{solution}
\ExplSyntaxOn
\clist_new:N \g_ljh_answer_clist
\cs_generate_variant:Nn \clist_if_in:NnT { NeT }
% 辅助宏 from: https://mp.weixin.qq.com/s/Mc3QawPiD6WnREZejFxigg
\cs_set_nopar:Npn \__module_range_to_list:nN #1#2 {
  \seq_set_split:Nnn \l__module_tmpa_seq { , } { #1 }
  \seq_map_inline:Nn \l__module_tmpa_seq 
  {
    \tl_if_in:nnTF { ##1 }{ - }
    {
      \seq_set_split:Nnn \l__module_tmpb_seq { - } { ##1 }
      \int_step_inline:nnn 
      { \seq_item:Nn \l__module_tmpb_seq { 1 } } 
      { \seq_item:Nn \l__module_tmpb_seq { 2 } } 
      {
        \clist_put_right:Nn #2 { ####1 }
      }
    }
    {
      \clist_put_right:Nn #2 { ##1 }
    }    
  }
}
\NewDocumentEnvironment{question}{+b}{
    \refstepcounter{question}
    \begin{leftbar}
    \noindent \textsf{Question\ \thequestion :}\quad {#1}
    \end{leftbar}
}{}
\NewDocumentEnvironment{solution}{+b}{
    \refstepcounter{solution}
    % why not \clist_if_in:NVT(?)
    \clist_if_in:NeT \g_ljh_answer_clist {\thesolution}
    {
        \begin{leftbar}
        \noindent \textsf{Solution\ \thesolution :}\quad {#1}
        \end{leftbar}
    }
}{}
\NewDocumentEnvironment{Exercises}{ o +b }{
    \group_begin:
    \setcounter{question}{0}
    \setcounter{solution}{0}
    \clist_gclear:N \g_ljh_answer_clist
    \IfNoValueTF{#1}
    {%这里的逻辑没处理太好,不太容易获取这个Exercises一共有多少题目
     %大胆一点...不过效率会不会变低呢(・∀・(・∀・(・∀・*)
        % \int_step_inline:nn {99}{\clist_gput_right:Nn \g_ljh_answer_clist {##1}}
        \__module_range_to_list:nN {1-99} \l_tmpa_clist
    }
    {
        \__module_range_to_list:nN {#1} \l_tmpa_clist
    }
    \clist_gset_eq:NN \g_ljh_answer_clist \l_tmpa_clist
    #2
    \group_end:
}{}
\ExplSyntaxOff
\begin{document}

\begin{Exercises}[1,3-4]
\begin{question}
    What is the meaning of life?
\end{question}

\begin{solution}
    The meaning of life is a philosophical question regarding the significance of life or existence in general. Many people and cultures have different interpretations of this concept.
\end{solution}

\lipsum[1]

\begin{question}
    What is the meaning of life?
\end{question}

\begin{solution}
    The meaning of life is a philosophical question regarding the significance of life or existence in general. Many people and cultures have different interpretations of this concept.
\end{solution}

\begin{question}
    What is the meaning of life?
\end{question}

\begin{solution}
    The meaning of life is a philosophical question regarding the significance of life or existence in general. Many people and cultures have different interpretations of this concept.
\end{solution}

\begin{question}
    What is the meaning of life?
\end{question}

\begin{solution}
    The meaning of life is a philosophical question regarding the significance of life or existence in general. Many people and cultures have different interpretations of this concept.
\end{solution}
\end{Exercises}


\newpage

\begin{Exercises}
\begin{question}
    What is the meaning of life?
\end{question}

\begin{solution}
    The meaning of life is a philosophical question regarding the significance of life or existence in general. Many people and cultures have different interpretations of this concept.
\end{solution}

\lipsum[2]

\begin{question}
    What is the meaning of life?
\end{question}

\begin{solution}
    The meaning of life is a philosophical question regarding the significance of life or existence in general. Many people and cultures have different interpretations of this concept.
\end{solution}

\begin{question}
    What is the meaning of life?
\end{question}

\begin{solution}
    The meaning of life is a philosophical question regarding the significance of life or existence in general. Many people and cultures have different interpretations of this concept.
\end{solution}

\end{Exercises}

\end{document}

image.png

来自Eureka的答案:

\documentclass[fontset=fandol]{ctexart}
\ctexset{section/format+={\raggedright}}
\renewcommand*{\tableofcontents}{%
  {\hfill\textbf{\Large\contentsname}\hfill}
  \UseName{@mkboth}%
    {\MakeUppercase\contentsname}%
    {\MakeUppercase\contentsname}%
  \UseName{@starttoc}{toc}%
}
\parindent=0pt
\begin{document}

\tableofcontents

\section{aaaa}

\section{bbbb}

\section{cccc}

\section*{ddd}

\end{document}

image.png

不过这里添加的代码量也相比稍长...

BTW,这里的样式为了保持一致,需要用到:

latexdef \section

\section:
\long macro:->\@startsection {section}{1}{\z@ }{-3.5ex \@plus -1ex \@minus -.2ex}{2.3ex \@plus .2ex}{\normalfont \Large \bfseries }

改的不是很好。

注意到amsart.sty中的:

% line 524~549
\def\@setaddresses{\par
  \nobreak \begingroup
\footnotesize
  \def\author##1{\nobreak\addvspace\bigskipamount}%
  \def\\{\unskip, \ignorespaces}%
  \interlinepenalty\@M
  \def\address##1##2{\begingroup
    \par\addvspace\bigskipamount\indent
    \@ifnotempty{##1}{(\ignorespaces##1\unskip) }%
    {\scshape\ignorespaces##2}\par\endgroup}%
  \def\curraddr##1##2{\begingroup
    \@ifnotempty{##2}{\nobreak\indent\curraddrname
      \@ifnotempty{##1}{, \ignorespaces##1\unskip}\/:\space
      ##2\par}\endgroup}%
  \def\email##1##2{\begingroup
    \@ifnotempty{##2}{\nobreak\indent\emailaddrname
      \@ifnotempty{##1}{, \ignorespaces##1\unskip}\/:\space
      \ttfamily##2\par}\endgroup}%
  \def\urladdr##1##2{\begingroup
    \def~{\char`\~}%
    \@ifnotempty{##2}{\nobreak\indent\urladdrname
      \@ifnotempty{##1}{, \ignorespaces##1\unskip}\/:\space
      \ttfamily##2\par}\endgroup}%
  \addresses
  \endgroup
}

其中关键的部分为

    \par\addvspace\bigskipamount\indent
    \@ifnotempty{##1}{(\ignorespaces##1\unskip) }%
    {\scshape\ignorespaces##2}\par\endgroup}%

可以修改为「去掉小括号」+「去掉地址的小型大写字体」+「修改缩进」 +「编组内给姓名设置小体大写」...

    \par\addvspace\bigskipamount
    %\indent
    % \@ifnotempty{##1}{(\ignorespaces##1\unskip) }%
    \@ifnotempty{##1}{{\scshape\ignorespaces\noindent##1\unskip\par}}%
    % {\scshape\ignorespaces##2}\par\endgroup}%
    {\ignorespaces\noindent##2}\par\endgroup}%

完整代码:

\documentclass[11pt]{amsart}

\makeatletter
\def\@setaddresses{\par
  \nobreak \begingroup
\footnotesize
  \def\author##1{\nobreak\addvspace\bigskipamount}%
  \def\\{\unskip, \ignorespaces}%
  \interlinepenalty\@M
  \def\address##1##2{\begingroup
    \par\addvspace\bigskipamount
    %\indent
    % \@ifnotempty{##1}{(\ignorespaces##1\unskip) }%
    \@ifnotempty{##1}{{\scshape\ignorespaces\noindent##1\unskip\par}}%
    % {\scshape\ignorespaces##2}\par\endgroup}%
    {\ignorespaces\noindent##2}\par\endgroup}%
  \def\curraddr##1##2{\begingroup
    \@ifnotempty{##2}{\nobreak\indent\curraddrname
      \@ifnotempty{##1}{, \ignorespaces##1\unskip}\/:\space
      ##2\par}\endgroup}%
  \def\email##1##2{\begingroup
    \@ifnotempty{##2}{\nobreak\indent\emailaddrname
      \@ifnotempty{##1}{, \ignorespaces##1\unskip}\/:\space
      \ttfamily##2\par}\endgroup}%
  \def\urladdr##1##2{\begingroup
    \def~{\char`\~}%
    \@ifnotempty{##2}{\nobreak\indent\urladdrname
      \@ifnotempty{##1}{, \ignorespaces##1\unskip}\/:\space
      \ttfamily##2\par}\endgroup}%
  \addresses
  \endgroup
}
\makeatother


\address[H. Zhu]{School of Physics and Information Engineering, Jiangsu Second Normal University, 6 Xinhe West Road, Shiqiu street, Nanjing 211200, P. R. China}
\email{\tt zhs@fudan.edu.cn}

\address[H. Song]{Department of Basic Courses, P. R. China}
\email{\tt s3@13.com}


\begin{document}

hello!

Here below is the permission:

\end{document}

这将得到:

image.png

BTW, 这无疑是编辑的无理需求...

灰原老师到此一游...
(其实是不慎把回复点成了答案)

第(2)问里面我找了过(1,0)和(1,2)的线段与AB相交得到C点,然后旋转,算是取巧,但总算是顺利画出来了

另外第(2)问是否还有别的合适的画法

其实注意到A(4,0)B(0,4),那么直线AB的方程显然是x+y=4,又因为x_C=1,瞪眼立得C(1,3),又因为旋转的是90°,再瞪眼又显然有D(3,-1)...

直接定下所有点的坐标,然后连线画图就行了😀...

并不需要照着题目的意思慢慢旋转,画图就要找最容易确定图形的思路(?)


第(3)问里面的等腰直角三角形有几个限制条件,我画不出来了

我觉得可以用要证的结论「BD+OB=AB」来取巧

因为要证的结论就一定是对的,这就免去了搜题这一步了😀.

注意到∠OBD=45°,而△OAB又是等腰直角,所以AB⊥CD. 又因为「BD=AB-OB=4√2-4」,所以其实只要确定了「D」点,它是AB过B的垂线,向左下延长「4(√2-1)」的长度得到的,即可唯一确定这个图形.

这样做顶多有一丢丢浮点误差,但是肉眼很难分辨的...

\documentclass[border=5pt]{standalone}
\usepackage{tkz-base}
\usepackage{tkz-euclide}
\begin{document}
\tkzSetUpLine[line width=.8pt]
\begin{tikzpicture}
\tkzInit[xmin=-1,xmax=5,ymin=-2,ymax=5]
\tkzDrawX[noticks,thick]
\tkzDrawY[noticks,right=2pt,thick]
\tkzDefPoints{0/0/O,0/4/A,4/0/B}
\def\lenBD{\fpeval{4*(\tkzSqrTwo-1)}}% 4(√2-1)

% 计算|BD|长度并定点
% \node {\lenBD};
\tkzDefPointWith[orthogonal normed,K=\lenBD](B,A) 
\tkzGetPoint{D}

% 利用角平分线确定M点
\tkzDefLine[bisector,normed](O,B,A) 
\tkzGetPoint{m}
\tkzInterLL(O,A)(B,m)
\tkzGetPoint{M}

% tkz-euclide可以很轻松地通过等腰直角三角形地斜边确定直角顶点
% 实际上手动求垂直平分线 + 确定交点也不难...
\tkzDefTriangle[isosceles right](O,D) 
\tkzGetPoint{C}

%
\tkzLabelPoints[below left](O)
\tkzLabelPoints[left](A,M)
\tkzLabelPoints[below](D,B)
\tkzLabelPoints[left](A,M)
\tkzLabelPoints[above](C)
\tkzDrawPolygons(O,A,B O,B,D O,B,M O,C,D)
\end{tikzpicture}
\end{document}

image.png

方案三:基于ctexheading提供的功能👇

image.png

但要尤其注意的是,在elegantbook.cls中使用的是:

% Line 194-221
\ifdefstring{\ELEGANT@lang}{cn}{
  \ifdefstring{\ELEGANT@chinesefont}{founder}{
    \RequirePackage[UTF8, scheme=plain, fontset=none]{ctex}
    \setCJKmainfont[BoldFont={FZHei-B01},ItalicFont={FZKai-Z03}]{FZShuSong-Z01}
    \setCJKsansfont[BoldFont={FZHei-B01}]{FZKai-Z03}
    \setCJKmonofont[BoldFont={FZHei-B01}]{FZFangSong-Z02}
    \setCJKfamilyfont{zhsong}{FZShuSong-Z01}
    \setCJKfamilyfont{zhhei}{FZHei-B01}
    \setCJKfamilyfont{zhkai}[BoldFont={FZHei-B01}]{FZKai-Z03}
    \setCJKfamilyfont{zhfs}[BoldFont={FZHei-B01}]{FZFangSong-Z02}
    \newcommand*{\songti}{\CJKfamily{zhsong}}
    \newcommand*{\heiti}{\CJKfamily{zhhei}}
    \newcommand*{\kaishu}{\CJKfamily{zhkai}}
    \newcommand*{\fangsong}{\CJKfamily{zhfs}}}{\relax}
  
  \ifdefstring{\ELEGANT@chinesefont}{nofont}{
    \RequirePackage[UTF8,scheme=plain,fontset=none]{ctex}
    \xeCJKsetup{AutoFakeBold=true}
    }{\relax}

  \ifdefstring{\ELEGANT@chinesefont}{ctexfont}{
    \RequirePackage[UTF8,scheme=plain]{ctex}
    \xeCJKsetup{AutoFakeBold=true}
    }{\relax}
  
  \AfterEndPreamble{
    \setlength\parindent{2\ccwd}}
}{\relax}
\RequirePackage[UTF8,scheme=plain]{ctex}

这并不会启用heading=true:

image.png

下面的workaround使用了\PassOptionsToPackage{heading=true}{ctex}:

\PassOptionsToPackage{heading=true}{ctex}
\documentclass[lang=cn,scheme=chinese]{elegantbook}
\usepackage{zhlipsum}
\usepackage{geometry}
\geometry{paperheight=10cm}
\begin{document}
\ctexset{chapter/pagestyle = fancy}

\chapter{标题标题}
\zhlipsum[2]

\chapter{标题标题}
\zhlipsum[2]
\end{document}

image.png

期待更多可能的回答~

方案二:使用etoolbox提供的\patchcmd命令:

\documentclass[lang=cn,scheme=chinese]{elegantbook}
\usepackage{zhlipsum}
\geometry{paperheight=10cm}
\patchcmd{\chapter}{\thispagestyle{plain}}{}{}{}
\begin{document}
\chapter{标题标题}
\zhlipsum[2]

\chapter{标题标题}
\zhlipsum[2]
\end{document}

image.png

方案一:使用fancyhdr提供的方案,将plain设置为fancy样式:

\documentclass[lang=cn,scheme=chinese]{elegantbook}
\usepackage{zhlipsum}
\geometry{paperheight=10cm}
\fancypagestyle{plain}[fancy]{}
\begin{document}
\chapter{标题标题}
\zhlipsum[2]

\chapter{标题标题}
\zhlipsum[2]
\end{document}

image.png

这看上去非常AI,直接拿着AI生成的代码提问可不是非常鼓励的...

  1. 请把你的代码补充完整(编辑问题),从\documentclss开始到\end{document}结束
  2. 请把你代码的编译截图也上传,具体指明是哪段代码在实现「标题与正文之间的距离调节」,但实际上没有改变

发布
问题