LaTeXStudio.net 问答 RSS 最新问答 https://ask.latexstudio.net/addons/ask/rss/index Sat, 13 Dec 2025 22:13:04 +0800 footline用tikz画直线为什么最左边有空隙 请问为什么footline中用tikz画直线,最左边有空隙。尝试了\hspace{-1pt},overlay,remember picture这些办法可以,是否可以不用这些,使得左边没有空隙。以下是代码

\documentclass{ctexbeamer}
\usepackage{tikz}
\usetikzlibrary{calc}
\setbeamertemplate{footline}{
   %\hspace*{-0.2pt}%
  \begin{tikzpicture}
    \def\r{1pt}
    \def\d{0.3pt}
    \coordinate (A) at (0,1.3em);
    \coordinate (B) at ($(A)+(0:{\paperwidth-(\r)-(\d)})$);
    \draw[red] (A)--(B);
    \fill[fill=white,line width=\d] (B) circle (\r);
    \node[anchor=south west,inner sep=0pt,outer sep=0pt,fill=red] at (0,0){\color{white}测试测试测试};
  \end{tikzpicture}
}
\begin{document}
\begin{frame}
  测试
\end{frame}
\end{document}

image.png

]]>
https://ask.latexstudio.net/ask/question/17977.html Thu, 11 Dec 2025 16:35:01 +0800
下载的国家标准模板编译出错 This compile didn’t produce a PDF. This can happen if: There is an unrecoverable LaTeX error. If there are LaTeX errors shown below or in the raw logs, please try to fix them and compile again. The document environment contains no content. If it’s empty, please add some content and compile again. This project contains a file called output.pdf. If that file exists, please rename it and compile again.

lightbulb Tip: Try to fix the first error and recompile. Often one error causes many later error messages. You can to focus on fixing errors. We recommend fixing errors as soon as possible; letting them accumulate may lead to hard-to-debug and fatal errors. Learn more

If you need to see the full logs, you can still download them or view the raw logs below.

]]>
https://ask.latexstudio.net/ask/question/17976.html Thu, 11 Dec 2025 14:40:52 +0800
如何实现这种带虚线的边框? cf64352b157d8e6b6f18c8356f12a4bd.png

想要复刻如图所示这种带虚线的边框和上下箭头,我的代码如下:

$\arraycolsep=1pt
\begin{array}{*1l@{\hskip\arraycolsep}c@{\hskip\arraycolsep}*{12}{>{\textstyle}l}}
x^3 & + & 2^3 & = (& x & + & 2) (& x^2 & - & x &\cdot& 2 & + & 2^2) \\
\bigg\updownarrow & & \bigg\updownarrow & & \bigg\updownarrow &  & \bigg\updownarrow & \bigg\updownarrow &  & \bigg\updownarrow & &\bigg\updownarrow & & \bigg\updownarrow \\
a^3 & + & b^3 & = (&a & + & b) (& a^2 & - & a&\cdot& b & + & b^2)
\end{array}$

实现效果

9c3c765118f431ca79b906a984c6b221.png

请教,如何实现带虚线的边框?

]]>
https://ask.latexstudio.net/ask/question/17974.html Mon, 08 Dec 2025 15:43:26 +0800
无法在 xeCJKfntef 宏包的 \CJKunderanyline* 命令中使用\zhlipsum 以及 \lisum 命令? 发行版texlive2025 编译命令:xelatex 问题\zhlipsum 以及 \lisum 命令无法使用 xeCJKfntef 宏包的 \CJKunderanyline* 命令?但 \newcommand\testtext 却可以在 \CJKunderanyline* 中使用 MWE: 如下

\documentclass{ctexart}
\usepackage{lipsum,zhlipsum}
\usepackage{xcolor}
\usepackage{xeCJKfntef}
\newcommand{\testtext}{我能吞下玻璃而不伤身体。我能吞下玻璃而不伤身体。我能吞下玻璃而不伤身体。我能吞下玻璃而不伤身体。}
\begin{document}
\CJKunderanyline*{0.5ex}{\color{cyan!10}\rule{2pt}{2.5ex}}{\zhlipsum[1]}
\CJKunderanyline*{0.5ex}{\color{cyan!10}\rule{2pt}{2.5ex}}{\lipsum[1]}

\CJKunderanyline*{0.5ex}{\color{cyan!10}\rule{2pt}{2.5ex}}{\testtext}

\CJKunderanyline*{0.5ex}{\color{cyan!10}\rule{2pt}{2.5ex}}{我能吞下玻璃而不伤身体。我能吞下玻璃而不伤身体。我能吞下玻璃而不伤身体。我能吞下玻璃而不伤身体。}
\end{document}

效果如下: image.png

]]>
https://ask.latexstudio.net/ask/question/17972.html Sat, 06 Dec 2025 08:34:19 +0800
行内盒子断行问题解决? 发行版:texlive2025overleaf) 编译方式:xelatex(或者 lualatex) 问题:想要在 elegantbook 文档类中实现行内盒子断行,但是 tcolorbox 行内盒子无法自动断行? 效果如下: image.png

盒子实现如下:

% 英文单词背景框(微调内边距,更舒展美观)
\newtcbox{\englishbox}{
    on line,
    boxrule=0pt,
    boxsep=1.5pt, % 盒内文字与边框的间距(比1pt舒展、比2pt紧凑)
    top=1pt,
    bottom=1pt,
    left=3pt, % 盒左侧内边距(比2pt更舒展)
    right=3pt, % 盒右侧内边距(比2pt更舒展)
    colback=cyan!10,
    colframe=cyan!10,
    arc=3pt,
    enhanced jigsaw
}

% 核心命令(保留你原有的写法)
\newcommand{\wordbox}[2]{%
    \englishbox{\textbf{#1}}% 
    \textcolor{blue!70!black}{(#2)}% 
}
]]>
https://ask.latexstudio.net/ask/question/17971.html Fri, 05 Dec 2025 22:57:35 +0800
为什么不能顺利绑定手机?一直点不到正确位置? 为什么不能顺利绑定手机?一直点不到正确位置?19843945548

]]>
https://ask.latexstudio.net/ask/question/17968.html Mon, 01 Dec 2025 19:58:36 +0800
circuitikz宏包绘制滑动电阻问题及微调元件位置 老师们好!请教一个绘制滑动电阻的问题及微调元件位置,要绘制的图片效果如下: PixPin_2025-11-30_19-53-41.jpg

目前绘制的效果如下: PixPin_2025-11-30_19-57-15.jpg

代码如下:

\documentclass{ctexbook}
\usepackage{circuitikz}

\begin{document}

\begin{circuitikz}[european]
    \draw(0,0)to[rmeter,t=A](0,2)to[R,l_=$R$](3,2)to[pR,l_=$R'$,n=pr](5,2);
    \draw(0,0)to[normal open switch](6,0)|-(pr.wiper);
\end{circuitikz}

\end{document}

不知道去除多余的线,不知道怎么调元件的位置。

]]>
https://ask.latexstudio.net/ask/question/17966.html Sun, 30 Nov 2025 19:58:35 +0800
使用exam-zh模板在windows下编译\subject命令出现字体警告?
  • win11
  • texlive2025
  • vscode
  • xelatex
  • \documentclass{exam-zh}
    \begin{document}
    % 设置试卷标题和科目
    \title{数学测试}
    \subject{数学}
    \maketitle
    % 第一道选择题
    \begin{question}
    $1 + 1 = $ \paren[C]
    \end{question}
    \end{document}

    取消\subject{},没有报错。

    LaTeX Font: Font shape `TU/SimHei(0)/b/n' undefined
    (Font)  using `TU/SimHei(0)/m/n' instead.

    不知道是什么原因,就是想解决他。

    ]]>
    https://ask.latexstudio.net/ask/question/17964.html Sat, 29 Nov 2025 09:57:50 +0800
    关于ieeecolor模板参考文献中缺少doi的问题 如下链接给出的「ieeecolor模板」Alternate-Transactions-Articles-LaTeX-template2.zip 中,使用了「ieeecolor」文档类,现在考虑如下的MWE:

    \documentclass[journal,twoside,web]{ieeecolor}
    \usepackage{generic}
    \usepackage{cite}
    \begin{filecontents*}[overwrite]{refs.bib}
    @article{mahon2017sg,
      title = {{The {5G} effect on {RF} filter technologies}},
      volume = {30},
      number = {4},
      journal = {{IEEE Transactions on Semiconductor Manufacturing}},
      author = {Mahon, Steven},
      year = {2017},
      pages = {494--499},
      doi={10.1109/TSM.2017.2757879},
    }
    @article{lee2018spectrum,
      title = {{Spectrum for {5G}: {Global} status, challenges, and enabling technologies}},
      volume = {56},
      number = {3},
      journal = {{IEEE Communications Magazine}},
      author = {Lee, Juho and Tejedor, Erika and Ranta-aho, Karri and Wang, Hu and Lee, Kyung-Tak and Semaan, Eliane and Mohyeldin, Eman and Song, Juyeon and Bergljung, Christian and Jung, Sangyeob},
      year = {2018},
      pages = {12--18},
      doi={10.1109/MCOM.2018.1700818},
    }
    \end{filecontents*}
    \bibliographystyle{IEEEtran}
    \begin{document}
    
    Hello world\cite{mahon2017sg} ahahahha\cite{lee2018spectrum} ahaha!
    
    \bibliography{refs}
    
    \end{document}

    这将得到:

    image.png

    但现在编辑要求在参考文献列表中增加「DOI」的字段信息,在当前的模板和.bib的框架下,满足编辑这一需求的最佳实践是什么?

    Edit

    需要指出的是,在上述链接里使用的模板根本没有考虑「DOI」的问题,但是编辑却要你考虑。

    这本身就是个非常不合理的要求!!!

    不是(不能、也不应该)让所有的投稿者都是「bibtex」砖家(至少我不是)

    ]]>
    https://ask.latexstudio.net/ask/question/17963.html Fri, 28 Nov 2025 13:21:13 +0800
    想问一下如何在居右的情况下,转行后“这”与“需”对齐 QQ20251128-101716.png

    \documentclass{ctexbook}
    \usepackage{titlesec,color,calc}
    
    \newcommand{\HZSBH}{\sffamily\bfseries\Large}
    \newcommand{\HYXSQS}{}
    
    \newlength{\chapterhang}
    
    \titleformat{\chapter}[hang]
      {\raggedleft\HZSBH\HYXSQS\color[cmyk]{1,1,0,0}}
      {第\thechapter 章}
      {1em}
      {\setlength{\chapterhang}{\widthof{第\thechapter 章}+1em}% 改动:+3em
       \makebox[0pt][r]{%
         \parbox[t]{\dimexpr\linewidth-\chapterhang-1em\relax}{%
           \setlength{\parindent}{0pt}%
           \parshape=2
             0pt \hsize
             \chapterhang \dimexpr\hsize-\chapterhang\relax
         }}}
    
    \titlespacing{\chapter}{0mm}{-6mm}{30mm}
    
    \begin{document}
    \chapter{这是一个很长的章节标题\\ 需要自动换行}
    \chapter{TCP服装参数优化}
    \end{document}
    ]]>
    https://ask.latexstudio.net/ask/question/17962.html Fri, 28 Nov 2025 10:19:22 +0800
    TeXstudio中无法使用asymptote来绘图 我准备在TeXstudio中使用asymptote来绘图。但pdf中无生成的图片。 Latex代码如下:

    \documentclass{article}
    \usepackage[pdftex]{graphicx}
    \usepackage{asymptote}
    \begin{document}
        Hello.  
        I like to make pics with Asymptote like this one:
        \begin{figure}[h]
            \begin{asy}
            import graph;
            size(1inch);
            filldraw(circle((0,0),1),yellow,black);
            fill(circle((-.3,.4),.1),black);
            fill(circle((.3,.4),.1),black);
            draw(arc((0,0),.5,-140,-40));
            \end{asy}
        \end{figure}
        \par It makes me happy, 
        since I can still type my normal LaTeX stuff around it: 
        \(\int_0^{\pi}{\sin{x}}\,dx=2\)
    \end{document}

    如果编译成功,pdf应为这样: 1.png

    但我用自己的TeXstudio编译,asymptote的图却无法显示. 2.png

    在文件夹中生成了一个.Asy文件 3.png

    打开这个.Asy的文档,里面内容如下:

    if(!settings.multipleView) settings.batchView=false;
    settings.tex="pdflatex";
    defaultfilename="例1-1";
    if(settings.render < 0) settings.render=4;
    settings.outformat="";
    settings.inlineimage=true;
    settings.embed=true;
    settings.toolbar=false;
    viewportmargin=(2,2);
    
    import graph;
    size(1inch);
    filldraw(circle((0,0),1),yellow,black);
    fill(circle((-.3,.4),.1),black);
    fill(circle((.3,.4),.1),black);
    draw(arc((0,0),.5,-140,-40));
    

    求助大佬,有什么建议和解决方法吗?非常感谢

    ]]>
    https://ask.latexstudio.net/ask/question/17959.html Mon, 17 Nov 2025 23:38:59 +0800
    使用 `tabularray` 绘制 `uml` 类图,如何控制`相对坐标`绘制直线的位置? 操作系统: Windows 11

    发行版: TeX Live 2025

    使用 Tabularray 绘制 uml 类图,我想出了两种方案

    • 将表格放在 node 节点里面, 使用 tikz 绘制直线

      \documentclass[tikz,border=10pt]{standalone}
      \usepackage{tabularray}
      \UseTblrLibrary{tikz}
      \usetikzlibrary{patterns,positioning}
      \begin{document}
      \begin{tikzpicture}[every node/.style = {inner sep=0pt}]
      \node (Circular)
      {
      \begin{tblr}{colspec={l},rowspec={cll}, row{1}={font=\bfseries},vlines,hlines}
      Circular \\
      bottom: Circle \\
      setBottom (Circle): void \\
      \end{tblr}
      };
      \node (Circle) [right=1cm of Circular]%
      {
      \begin{tblr}{colspec={l},rowspec={cll},row{1}={font=\bfseries},vlines,hlines}
      Circle \\
      radius: double \\
      getArea(): double \\
      \end{tblr}
      };
      
      \draw[->,red,thick] (Circular.east)--(Circle.west);
      \end{tikzpicture}
      \end{document}

      image.png

    • 使用 tabularray 的实验性库 tikz, 将两个类图放在同一张表格里,使用单元格节点控制直线的位置(这个方案目前看来最简单, 但由于拓展性不强放弃了(如果需要调整多个绘图代码,则需要反复调整表格的布局))

      \documentclass[border=10pt]{standalone}
      \usepackage{tabularray}
      \UseTblrLibrary{tikz}
      \usetikzlibrary{patterns,positioning}
      \begin{document}
      \begin{tblrtikzabove}
      \draw[thick,red,->] (1-1.mid east)--(1-3.mid west);
      \end{tblrtikzabove}
      \begin{tblr}{colspec={lQ[2cm]l},rowspec={cll}, row{1}={font=\bfseries},vlines,hlines={1,3}{solid}}
      Circular & & Circle \\
      bottom: Circle & & radius: double \\
      setBottom (Circle): void & & getArea(): double \\
      \end{tblr}
      \end{document}

      image.png

    问题:

    在第一个方案中如何控制相对坐标绘制的直线:

    \draw[->,red,thick] (Circular.east)--(Circle.west);

    (使用 shift 选项无效!!)

    ]]>
    https://ask.latexstudio.net/ask/question/17957.html Sun, 16 Nov 2025 08:18:15 +0800
    顶部导航条如何使用section短标题 在beamer中的使用“\insertshortsectionnavigationhorizontal{\textwidth}{}{}”插入section标题导航,现在section标题太长,且不可更改,如何使用section的短标题设置导航条?

    ]]>
    https://ask.latexstudio.net/ask/question/17956.html Sat, 15 Nov 2025 22:23:38 +0800
    在alogorithm2e宏包中如何设置`While`后的关键字为宋体/罗马正体? 如题,下面的mwe:

    \documentclass[fontset=fandol]{ctexart}
    \usepackage{graphicx} % Required for inserting images
    \usepackage[ruled,vlined,linesnumbered]{algorithm2e}
     \usepackage{amsmath}
    \title{试验}
    \author{834640568 }
    \date{July 2025}
    
    \begin{document}
    
    \maketitle
    
    \section{Introduction}
    
    \begin{algorithm}[htb]%算法3.1
    \caption{p-VQD算法}
    \label{algo:3.1} % 自动编号,可通过 \ref{algo:algorithm} 引用
    \small
    \SetAlgoLined
    \KwData{哈密顿量 $H$, 时间步长 $\Delta t$,时间步数$n$,初态$|\psi_0 \rangle$,梯度范数阈值$\text{grad}_{\text{tol}}$,迭代次数上限$\text{count}_\text{{max}}$,依赖参数$\theta$的量子电路$U(\theta)$}
    \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$\;%重复步骤3-8\;
        求惩罚函数的梯度$\nabla_{\theta}C(\theta)$     \;
        \While{\text{$|\nabla_{\theta}C(\theta)| > \text{grad}_{\text{tol}}$ \text{且} $\text{count} < count_{\text{max}}$}}{
        根据梯度$\nabla_{\theta}C(\theta)$,利用ADAM优化器更新参数$\theta$  \;
        $\text{count}$加1   \;
        求惩罚函数的梯度$\nabla_{\theta}C(\theta)$     \;
        }
    }  
    \end{algorithm}
    
    \end{document}

    但是这里的字体为斜体,希望修改为罗马正体。

    ]]>
    https://ask.latexstudio.net/ask/question/17953.html Tue, 11 Nov 2025 19:31:56 +0800
    在elegantbook模板中如何修改「proof」命令为带编号的形式? 如题,现在希望「proof」环境带编号:

    image.png

    MWE:

    \documentclass[lang=cn]{elegantbook}
    \usepackage{zhlipsum}
    \begin{document}
    
    \begin{proof}[(2)]
        显然。这是一个证明:\zhlipsum[2]。
    \end{proof}
    
    \end{document}

    image.png

    ]]>
    https://ask.latexstudio.net/ask/question/17952.html Tue, 11 Nov 2025 13:05:26 +0800
    elegantbook中的lang=cn对\bibname的覆盖失效? 如题,考虑如下MWE:

    \documentclass[
        lang=cn,fontset=fandol,
    ]{elegantbook}
    \geometry{paperheight=8cm}
    \addbibresource{xampl.bib}
    % \AtBeginDocument{%
    %     \renewcommand{\bibname}{参考文献}
    % }
    \begin{document}
    
    \chapter{第一章}
    Hello\cite{article-minimal} World! 中文!
    
    \printbibliography
    
    % \printbibliography[title={参考文献}]
    
    \end{document}

    elegantbook.cls模板中,上述代码表现为:

    image.png

    注意到在elegantbook.cls中的:

    % Line 21
    \DeclareStringOption[en]{lang}

    设置了默认值为lang=en

    且有:

    % Line 411
    \ifdefstring{\ELEGANT@lang}{cn}{
      \renewcommand{\baselinestretch}{1.3}
      \renewcommand{\contentsname}{目录}
      \renewcommand{\figurename}{图}
      \renewcommand{\tablename}{表}
      \renewcommand{\partname}{\color{structurecolor}}
      \renewcommand{\thepart}{第\zhnumber{\arabic{part}}部分}
      \renewcommand{\listfigurename}{插图目录}
      \renewcommand{\listtablename}{表格目录}
      \renewcommand{\bibname}{参考文献}
      \newcommand{\ebibname}{参考文献}
      \renewcommand{\appendixname}{附录}
      \renewcommand{\appendixtocname}{附录}
      \renewcommand{\indexname}{索\hspace{2em}引}
      \newcommand\figref[1]{\textbf{图}~\ref{#1}}
      \newcommand\tabref[1]{\textbf{表}~\ref{#1}}
      \newcommand{\authorname}{\citshape 作者:}
      \newcommand{\institutename}{\citshape 组织:}
      \newcommand{\datename}{\citshape 时间:}
      \newcommand{\versionname}{\citshape 版本:}
      \newcommand{\notename}{笔记}
      \renewcommand*{\proofname}{证明}
      \newcommand{\definitionname}{定义}
      \newcommand{\theoremname}{定理}
      \newcommand{\axiomname}{公理}
      \newcommand{\postulatename}{公设}
      \newcommand{\lemmaname}{引理}
      \newcommand{\propositionname}{命题}
      \newcommand{\corollaryname}{推论}
      \newcommand{\examplename}{例题} %
      \newcommand{\instancename}{示例} %
      \newcommand{\problemname}{问题} % 问题
      \newcommand{\exercisename}{练习} % 练习=习题
      \newcommand{\remarkname}{注}
      \newcommand{\assumptionname}{假设}
      \newcommand{\conclusionname}{结论}
      \newcommand{\solutionname}{解}
      \newcommand{\propertyname}{性质}
      \newcommand{\introductionname}{内容提要}
      \newcommand\bioinfo[2]{\gdef\@bioinfo{{\citshape #1}:#2}}
      \newcommand{\updatename}{更新:}
      \newcommand{\historyname}{版本更新历史}
      \newcommand{\beforechap}{第}
      \newcommand{\afterchap}{章}
    }{\relax}

    但在MWE中的表现却为:

    • \chaptername正确更改
    • \bibname并未正确更改

    这是不是elegant-latex在lang=cn时的非预期行为呢?


    BTW,使用:

    \printbibliography[title={参考文献}]

    或者

    \AtBeginDocument{%
        \renewcommand{\bibname}{参考文献}
    }

    都能满足需求,但不是问题的关键。

    Edited:

    使用意大利语方案lang=it,似乎一切正常...

    \documentclass[lang=it]{elegantbook}
    \geometry{paperheight=8cm}
    \addbibresource{xampl.bib}
    \begin{document}
    \chapter{Chapter Name}
    Hello\cite{article-minimal} World! 
    
    \printbibliography
    \end{document}

    image.png

    ]]>
    https://ask.latexstudio.net/ask/question/17951.html Mon, 10 Nov 2025 16:48:16 +0800
    这个模板我想把前面的这些无关内容删去 模板压缩包

    我都不知道我编译出来的pdf在哪个pdf ,而且我不想多余的部分image.png

    然后image.png

    这张图片里有一些小异常 想变成 image.png 符号完整 和 image.png 对齐

    ]]>
    https://ask.latexstudio.net/ask/question/17947.html Thu, 30 Oct 2025 18:15:24 +0800
    关于amsart修改permission页面样式的问题? 如下mwe:

    \documentclass[11pt]{amsart}
    
    \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

    现在的目标是要修改为:

    image.png

    ]]>
    https://ask.latexstudio.net/ask/question/17946.html Tue, 28 Oct 2025 19:29:12 +0800
    「elegantbook-latex日经问题」如何让「\chapter」页也正常显示页码? 如题,希望使用elegantbook模板实现让「\chapter」的首页也显示正常的页码?

    虽然这是book.cls文档类的默认行为,也是大多数book排版的惯例:

    % book.cls Line 350~354
    \newcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi
                        \thispagestyle{plain}%
                        \global\@topnum\z@
                        \@afterindentfalse
                        \secdef\@chapter\@schapter}

    下面是MWE:

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

    image.png

    ]]>
    https://ask.latexstudio.net/ask/question/17944.html Sun, 26 Oct 2025 19:34:06 +0800
    标题与正文之间的距离调节没有反应怎么办? % 一级标题:第一章 绪论(对应\section) \titleformat{\section}[block] {% 字体设置 \centering % 居中对齐 \bfseries % 加粗 \fontsize{16pt}{16pt}\selectfont % 三号字(16pt),单倍行距 \CJKfontspec{SimHei}% 中文黑体 \fontspec{Times New Roman}% 西文Times New Roman } {\thesection}% 题序(如"第一章") {1\ccwd}% 题序与标题间空1个汉字宽度(1个空格) {}% 标题内容前无额外内容 {} \titlespacing{\section} {0pt}% 左缩进 {15.6pt}% 段前距离 {15.6pt}% 段后距离 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 二级标题:1.1 研究背景(对应\subsection) \titleformat{\subsection}[block] {% 字体设置 \raggedright % 左对齐 \bfseries % 加粗 \fontsize{14pt}{14pt}\selectfont % 四号字(14pt),单倍行距 \CJKfontspec{SimHei}% 中文黑体 \fontspec{Times New Roman}% 西文Times New Roman } {\thesubsection}% 题序(如"1.1") {1\ccwd}% 题序与标题间空1个汉字宽度(1个空格) {}% 标题内容前无额外内容 {} \titlespacing{\subsection} {0pt}% 左缩进 {9.1pt}% 段前距离 {9.1pt}% 段后距离 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %三级标题 % 2. 字体与样式(严格匹配要求) \titleformat{\subsubsection}[block] {% \raggedright % 左对齐(无缩进) \bfseries % 加粗 \fontsize{12pt}{12pt} % 小四号(12pt),单倍行距(标题自身行距=字号) \CJKfontspec{SimHei}% 中文黑体 \fontspec{Times New Roman}% 西文Times New Roman } {\thesubsubsection}% 题序(如"1.4.1") {1\ccwd}% 题序与标题间空1个汉字宽度(1个空格) {}% 标题内容前无额外内容 {} \titlespacing{\subsubsection} {0pt}% 左缩进(无) {8pt}% 段前0.5行(基于当前字体的行高) {8pt}% 段后0.5行 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %四级标题 % 四级标题完整配置(确保显示) % 四级标题完整配置(与三级标题一致) \newcounter{subsubsubsection}[subsubsection] \renewcommand{\thesubsubsubsection}{\arabic{section}.\arabic{subsection}.\arabic{subsubsubsection}.\arabic{subsubsubsection}} \titleformat{\subsubsubsection}[block] {% \raggedright \bfseries \fontsize{12pt}{15.6pt}\selectfont \CJKfontspec{SimHei} \fontspec{Times New Roman} } {\thesubsubsubsection} {1\ccwd} {} {} % 无额外命令 \titlespacing{\subsubsubsection} {0pt} {8pt}% 段前0.5行 {8pt}% 段后0.5行(固定值,与三级标题一致) % 简化自定义命令,移除强制行距 \newcommand{\subsubsubsection}[1]{% \par \refstepcounter{subsubsubsection}% {\raggedright\bfseries\fontsize{12pt}{15.6pt}\selectfont\CJKfontspec{SimHei}\fontspec{Times New Roman}% \thesubsubsubsection\hspace{1\ccwd}#1\par}% } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 创建独立正文环境(强制固定行距20磅) \newenvironment{maintext}{% \begingroup% 局部作用域,隔离外部设置 \interlinepenalty=0% 允许段落分页 \brokenpenalty=0% 允许段落跨页 \raggedbottom % 1. 核心:强制行距为20pt,不缩放 \linespread{1}\selectfont% 禁用行距缩放(关键!避免setspace宏包干扰) \fontsize{12pt}{20pt}\selectfont% 字号12pt,行距绑定为20pt(第二个参数直接控制\baselineskip) % 2. 锁定行距参数,不允许小于20pt \setlength{\baselineskip}{20pt}% 显式设置基线距为20pt(双重保障) \setlength{\lineskiplimit}{19.9pt}% 允许行距最小为19.9pt(仅比20pt小0.1pt,确保正文内强制20pt) \setlength{\lineskip}{20pt}% 多行环境(如列表、表格)强制行距20pt % 3. 正文格式设置 \justifying% 两端对齐 \setlength{\parskip}{0pt}% 段落间距0(避免干扰) \setlength{\parindent}{2em}% 首行缩进2字符 \frenchspacing% 取消句末额外空格 % 4. 确保表格内行距同步为20pt \AtBeginEnvironment{tabular}{\fontsize{12pt}{20pt}\selectfont\setlength{\baselineskip}{20pt}} % 5. 移除\everypar强制命令(避免干扰标题后第一个段落) }{% \endgroup% 结束局部作用域 } ]]> https://ask.latexstudio.net/ask/question/17943.html Sat, 25 Oct 2025 15:24:50 +0800