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

注册于 3年前

回答
456
文章
0
关注者
15

这个问题太长了,目测OP在原问题上花的时间和精力并不多。

没有细看,但是AI在一个如此庞大的和精细的需求里是不给力的

但是无法运行,有很多报错

那理应贴出来报错信息。

side-notes:

\usepackage{xcolor} % 用于定义颜色
\usepackage{xparse} % 用于定义带有可选参数和默认值的命令

这两行都是不需要的,tikz内部调用了xcolor;且xparse早已进入内核,因此都不需要显式调用。


第一个报错是:

! Undefined control sequence.
<argument> ..._highlight_color_tl {\keys_value:nn
                                                  {tikzhl}{highlight-color}}
l.91 ...其中包含一些 \tikzhl{需要高亮}
                                                   的内容。
?

很显然,在interface3.pdf中并不能搜索到\keys_value:nn这个API...

\tl_set:Nx \l_tikzhl_highlight_color_tl { \keys_value:nn { tikzhl } { highlight-color } }
\tl_set:Nx \l_tikzhl_underline_thickness_tl { \keys_value:nn { tikzhl } { underline-thickness } }
\tl_set:Nx \l_tikzhl_underline_color_tl { \keys_value:nn { tikzhl } { underline-color } }
\tl_set:Nx \l_tikzhl_corner_radius_tl { \keys_value:nn { tikzhl } { corner-radius } }

上面几行都显然是是错的...

一般来说,l3keys里类似的需求也许会这么写:

\keys_define:nn { foo / blockstyle } {
    bordercolor .tl_set:N = \l_foo_border_color_tl,
    backgroundcolor .tl_set:N = \l_foo_background_color_tl,
    textcolor .tl_set:N = \l_foo_text_color_tl,
    textstyle .tl_set:N = \l_foo_text_style_tl,
}

但这基本上要重写代码,而且需要别人先理解你的原始需求,再理解ai的实现过程,我不喜欢读ai生产的垃圾....


第二个错误:

! Package pgfkeys Error: I do not know the key '/tikz/innersep', to which you p
assed '\dim_use:N \l_tikzhl_padding_dim ', and I am going to ignore it. Perhaps
 you misspelled it.

See the pgfkeys package documentation for explanation.
Type  H <return>  for immediate help.
 ...

l.91 ...其中包含一些 \tikzhl{需要高亮}
                                                   的内容。
?

另一个很显然的问题是,在\ExplSyntaxOn/Off对里,空格均会被忽略,因此带空格的rounded cornersline width都应该加上~.....

改不动了....一定不会有后续了...Happy LaTeX3!

此事在lshort中亦有记载

image.png

0.你原先的代码还是有大量和问题无关的内容,他们理应被删去,不要给别人增加代码阅读量!!:

\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{float}
\usepackage{cases}
\usepackage[font={small,rm}]{caption}
\DeclareGraphicsRule{.jpg}{eps}{.bb}{}
\newtheorem{theorem}{Theorem}
\newtheorem{corollary}{Corollary}
\newtheorem{definition}{Definition}
\newtheorem{lemma}{Lemma}
\newtheorem{proposition}{Proposition}
\newtheorem{algorithm}{Algorithm}
\newtheorem{assumption}{Assumption}
\newtheorem{remark}{Remark}
\renewcommand{\baselinestretch}{1.0}
\allowdisplaybreaks

1.加上\nonumber就可以去掉编号
2.我在最后一行加上了\quad,让末两行看上去是「同一个公式(折行)」

\documentclass[twocolumn]{IEEEtran}
\usepackage{mathrsfs}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{empheq}
\begin{document}
\begin{subequations}
\begin{empheq}
[left={\textbf{OP1}:\empheqlbrace}]{align}
&\underset{u}{\min}~ \psi\\
&\mathrm{s.t.}~~J_{\infty}(s) \leq \psi\\
&\underset{p}{\max}\left|\left[u(s)\right]_p\right|\leq \bar{u}, \\
&\underset{q}{\max}\left|\left[x(s+1|s)\right]_q\right|\leq \bar{x},\\                                     
& \mathscr{E}\{V(\phi(s))\}-V(\phi(s))\\
& \quad \leq  -z^{\mathrm{T}}(s)z(s)+\rho d^{\mathrm{T}}(s)d(s). \nonumber
\end{empheq}
\end{subequations}
\end{document}

image.png


Edit:

感觉这样更好看...

换行后又多增加一个标号1f(其实是一个公式),需要如何去掉1f呢?

表意不明,差评!

\documentclass[twocolumn]{IEEEtran}
\usepackage{mathrsfs}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{empheq}
\begin{document}
\begin{subequations}
\begin{empheq}
[left={\textbf{OP1}:\empheqlbrace}]{align}
&\underset{u}{\min}~ \psi\\
&\mathrm{s.t.}~~J_{\infty}(s) \leq \psi\\
&\underset{p}{\max}\left|\left[u(s)\right]_p\right|\leq \bar{u}, \\
&\underset{q}{\max}\left|\left[x(s+1|s)\right]_q\right|\leq \bar{x},\\                                     
& \mathscr{E}\{V(\phi(s))\}-V(\phi(s))\nonumber\\
& \qquad \leq  -z^{\mathrm{T}}(s)z(s)+\rho d^{\mathrm{T}}(s)d(s). 
\end{empheq}
\end{subequations}
\end{document}

image.png

需求(a) 不希望「同解,求值」出现在第二栏,改用\vspace而不是\vspace*即可:

\documentclass[twocolumn,12pt]{ctexart}
\usepackage{showframe}
\usepackage[type=lowerleft]{fgruler}
\usepackage[paperwidth=42cm,paperheight=29.7cm,top=3cm,bottom=1cm,left=1.7cm,right=1.7cm,bindingoffset=0.5cm]{geometry}
\setlength{\columnsep}{35pt}%设置两栏之间的间距
\raggedbottom
\begin{document}
        (1) *********************  
        \vspace*{8cm}

        (2) ********************* 
        \vspace*{8cm}
        
        (3) 已知齐次线性方程组  
        \[
        *******************
        \]  
        同解,求 $a,b,c$ 的值.
        \vspace{8cm}
        
        (4) 已知齐次线性方程组 
\end{document}

image.png

需求(b) 希望得到可跨行的\vspace:

参考链接: https://tex.stackexchange.com/questions/601243/vspace-at-the-end-of-a-page

方法一:

\documentclass[twocolumn,12pt]{ctexart}
\usepackage{showframe}
\usepackage[type=lowerleft]{fgruler}
\usepackage[paperwidth=42cm,paperheight=29.7cm,top=3cm,bottom=1cm,left=1.7cm,right=1.7cm,bindingoffset=0.5cm]{geometry}
\setlength{\columnsep}{35pt}%设置两栏之间的间距
\raggedbottom
% % https://tex.stackexchange.com/a/601258/322482
\usepackage{forloop}
\newcounter{vspaceinc}
\newcommand\xvspace[2]{\par\leavevmode%
  \forloop{vspaceinc}{0}{\thevspaceinc<#1}{%
  \vspace{\dimexpr1#2-\baselineskip-\parskip}\leavevmode\par}%
}
\begin{document}
        (1) *********************  
        \vspace*{8cm}

        (2) ********************* 
        \vspace*{8cm}
        
        (3) 已知齐次线性方程组  
        \[
        *******************
        \]  
        同解,求 $a,b,c$ 的值.
        \xvspace{12}{cm}
        
        (4) 已知齐次线性方程组 
\end{document}

方法二:

\documentclass[twocolumn,12pt]{ctexart}
\usepackage{showframe}
\usepackage[type=lowerleft]{fgruler}
\usepackage[paperwidth=42cm,paperheight=29.7cm,top=3cm,bottom=1cm,left=1.7cm,right=1.7cm,bindingoffset=0.5cm]{geometry}
\setlength{\columnsep}{35pt}%设置两栏之间的间距
\raggedbottom
% https://tex.stackexchange.com/a/601262/322482
\newlength{\gapinsert}
\newcommand{\insertgap}[1]{%
  \par
  \ifdim\dimexpr\pagegoal-\pagetotal<#1
    % Capture space remaining after page break
    \setlength{\gapinsert}{\dimexpr#1-\pagegoal+\pagetotal}%
    \pagebreak% Insert page break
    \vspace*{\gapinsert}% Insert additional/remaining gap; https://tex.stackexchange.com/q/33370/5764
  \else
    % Enough space available on page
    \vspace{#1}% Insert regular vspace
  \fi
}
\begin{document}
        (1) *********************  
        \vspace*{8cm}

        (2) ********************* 
        \vspace*{8cm}
        
        (3) 已知齐次线性方程组  
        \[
        *******************
        \]  
        同解,求 $a,b,c$ 的值.
        \insertgap{12cm}
        
        (4) 已知齐次线性方程组 
\end{document}

image.png

@u73286 Eureka老师补充了一个回答,基于tikzfadings库:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{fadings}
\begin{document}

% the clipping text
\begin{tikzfadingfrompicture}[name=title]
  \node [text=transparent!0, text width=0.7\paperwidth, align=center, font=\fontfamily{ptm}\bfseries\scshape, scale=3]
    {TH};
\end{tikzfadingfrompicture}

% use it to clip your image
\begin{tikzpicture}
  \node[scope fading=title,fit fading=false] (0,0) {
    \begin{tikzpicture}
      \shade[left color=red, right color=blue] (0,0) rectangle (2,1);
    \end{tikzpicture}
  };
\end{tikzpicture}
\end{document}

image.png

巧妇也难为无米之炊...

是不是应该贴一个能体现你问题的代码例子...包括模板的链接,也建议贴一贴...

另外,不是所有文章在被引用时都会「变为可以点击的超链接形式」

image.png

虽然我不太熟悉beamer...

但也许可以在文档第九章里简单用\visible叠层规则实现(?)

\documentclass{ctexbeamer}
\newcommand\myparaphase[1]{%
    \textcolor{red}{#1}%
}%
\begin{document}
\begin{frame}{屈原列传}
屈原者,名平,楚之同姓(
\visible<2->{\myparaphase{相同姓氏}}%<-吞掉空格
)也。为楚怀王左徒。博闻强志,明于治(
\visible<3->{\myparaphase{指国家安定}}%
)乱(
\visible<4->{\myparaphase{指国家动荡}}%
) ,娴(
\visible<5->{\myparaphase{熟悉}}%
)于辞令。入则与王图议国事,以出号令;出则接遇宾客,应对诸侯。王甚任之。
\end{frame}
\end{document}

mweres.gif

上面的代码其实cleverref会报警告:

LaTeX Warning: Reference `lem' on page 1 undefined on input line 18.
LaTeX Warning: Reference `lem' on page 1 undefined on input line 18.

此事在下面的几个链接里都有记载:

目前来看的最佳实践似乎是:

\documentclass{article}
\usepackage{amsthm}
\usepackage{cleveref}
\newtheorem{thm}{Theorem}[section]
\newtheorem{lem}[thm]{Lemma}
\AddToHook{env/lem/begin}{\crefalias{thm}{lem}}

\crefname{lem}{lemma}{lemmas}
\Crefname{lem}{Lemma}{Lemmas}
\begin{document}
  \begin{thm}\label{thm}
    foo
  \end{thm}
  \begin{lem}\label{lem}
    foo
  \end{lem}
  \noindent
  \cref{lem}, \Cref{lem}
\end{document}

image.png

似乎在firstaid中已经修了...但我不太懂这个...

最后补充一下「我本地TL2025会出问题」的内核和宏包版本(\listfiles):

 *File List*
 article.cls    2025/01/22 v1.4n Standard LaTeX document class
  size10.clo    2025/01/22 v1.4n Standard LaTeX file (size option)
  amsthm.sty    2020/05/29 v2.20.6
cleveref.sty    2018/03/27 v0.21.4 Intelligent cross-referencing
l3backend-pdftex.def    2025-04-14 L3 backend support: PDF output (pdfTeX)

看看bending

看看Triangle Cap样式...

同时效果差是怎么个差法...请具体用图例描述你的预期需求

最重要的一点,你的代码还是太长

重点是「曲线箭头」

  • 这与你的axis环境有关系吗?
  • 与你的一系列字体设置又有何关系?

望简化代码再提问

个人猜测你遇到的「上下字体不统一」的原因是:

  • 下方的内容使用的是\xlongequal的原生功能
  • 上方的内容使用的是array,其对行距和字体的大小控制不太相同

对于「位置与内容呈现明显对偶关系」的内容, 最好 不要用不同的方式排版

事实上,最轻量级的amsamath宏包即提供了\substack的功能:

\documentclass{article}
\usepackage{newpxmath}% change the font to palatino style
\usepackage{amsmath}
\usepackage{extarrows}
\begin{document}
\[
\begin{vmatrix} 
    1 & 1 & 1 & 1 \\ 
    1 & 1 & 0 & -5 \\ 
    -1 & 3 & 1 & 3 \\ 
    2 & -4 & -1 & -3 
\end{vmatrix}
\xlongequal[r_2-r_1]{\substack{r_4+2r_3\\[3pt]r_3+r_1}}
    \begin{vmatrix} 
    1 & 1 & 1 & 1 \\ 
    0 & 0 & -1 & -6 \\ 
    0 & 4 & 2 & 4 \\ 
    0 & 2 & 1 & 3 
\end{vmatrix}
\]
\end{document}

另外,直接用vmatrix环境比\left|\right|更优雅....

image.png

请提供完整代码....不然谁能知道你是怎么排出来这个效果的...

image.png

Learning from egreg's elegant solution by box manipulation:

\documentclass{article}
\usepackage{amsmath,amsfonts}
\newcommand{\lastcfrac}[2]{%
      \raisebox{\dimexpr1ex-\height}{%
        $\displaystyle
          \raisebox{.5\height}{$\ddots$}+\cfrac{#1}{#2}
        $%
      }%
    }
\begin{document}
    \[
        q_0 + \cfrac{1}{q_1 + \cfrac{1}{q_2 + \ddots +\cfrac{1}{q_n}}} 
    \]

    \[
        q_0 + \cfrac{1}{q_1 + \cfrac{1}{q_2+\lastcfrac{1}{q_n}}} 
    \]
\end{document}

image.png

嗯..我个人觉得比原图的省略号更美观...

Claim:其实这更多的是一个数学问题...

个人探索的另一个更优雅和直观的方式是基于「一些神必的数学」

image.png

而更碰巧的是,tikz提供了「coordinate transformation matrix」这样的feature

所以可以得到如下个人觉得比较简单的实现:

\documentclass[tikz,border=5pt]{standalone}
\begin{document}
\def\radius{1}
\def\height{1.05}%to tune the eccentricity
\def\leftheight{2}
\def\rightheight{4}
\def\midheight{\fpeval{(\leftheight+\rightheight)/2}}
\def\hh{\fpeval{abs(\leftheight-\rightheight)/2}}
\begin{tikzpicture}[line join=round]
    \draw[dashed] (\radius,0) arc (0:180:{\radius} and {1/3});
    \draw (-\radius,0) arc (180:360:{\radius} and {1/3});
    \draw (-\radius,0) -- (-\radius,\leftheight) coordinate (A);
    \draw (\radius,0) -- (\radius,\rightheight) coordinate (B);
    \def\phii{\fpeval{acos(\hh/\height)}}
    \def\xa{0}
    \def\ya{\fpeval{-\height*sin(\phii)}}
    \def\xb{\radius}
    \def\yb{\fpeval{\height*cos(\phii)}}
    \draw[cm={\xa,\ya,\xb,\yb,(0,\midheight)}] circle [radius=1cm];
    \filldraw[red] (A) circle[radius=.5pt] node[left,text=black] {$A$}
                   (B) circle[radius=.5pt] node[right,text=black] {$B$};
    \node[align=left,rectangle] at (\radius+4,\rightheight/2) {%
        $\phi$ \texttt{=\phii}\\
        $(x_1,y_1)$ \texttt{=(\xa,\ya)}\\
        $(x_2,y_2)$ \texttt{=(\xb,\yb)}
    };
\end{tikzpicture}
\end{document}

image.png

欣赏一下局部细节

image.png

Edit

忽然想到:

要欣赏一下局部细节

tikz提供了spy这样的工具,尝尝鲜嘻嘻

\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{spy}
\begin{document}
\def\radius{1}
\def\height{1.05}%to tune the eccentricity
\def\leftheight{2}
\def\rightheight{4}
\def\midheight{\fpeval{(\leftheight+\rightheight)/2}}
\def\hh{\fpeval{abs(\leftheight-\rightheight)/2}}
\begin{tikzpicture}[
    line join=round,
    line cap=round,
    spy using outlines={%
        circle,size=2cm,
        magnification=10,
        connect spies
    }%
]
    \draw[dashed] (\radius,0) arc (0:180:{\radius} and {1/3});
    \draw (-\radius,0) arc (180:360:{\radius} and {1/3});
    \draw (-\radius,0) -- (-\radius,\leftheight) coordinate (A);
    \draw (\radius,0) -- (\radius,\rightheight) coordinate (B);
    \def\phii{\fpeval{acos(\hh/\height)}}
    \def\xa{0}
    \def\ya{\fpeval{-\height*sin(\phii)}}
    \def\xb{\radius}
    \def\yb{\fpeval{\height*cos(\phii)}}
    \draw[cm={\xa,\ya,\xb,\yb,(0,\midheight)}] circle [radius=1cm];
    \node[align=left,rectangle] at (\radius+4,1) {%
        $\phi$ \texttt{=\phii}\\
        $(x_1,y_1)$ \texttt{=(\xa,\ya)}\\
        $(x_2,y_2)$ \texttt{=(\xb,\yb)}
    };
    \spy[red] on (A) in node [left] at (-1,4);
    \spy[blue] on (B) in node [right] at (2.5,3);
\end{tikzpicture}
\end{document}

image.png

这是一个不太好的解答,但提供了一个倾斜椭圆绘制的轮子...

要想更方便地仅通过椭圆的「长轴端点」和「离心率」来控制「倾斜」的椭圆,我正好在这里有一个类似的封装\mydrawellipse

稍微调整了一下:

\documentclass[tikz,border=2pt]{standalone}
\usepackage{tkz-euclide}
\NewDocumentCommand{\mydrawellipse}{O{}O{}mmm}{%
  % #3=pointA; #4=pointB; #5=ratio of y on x
  \tkzCalcLength(#3,#4)%
  \tkzGetLength{tmpdistance}%
  \tkzFindSlopeAngle(#3,#4) %
  \tkzGetAngle{tmpangle}%
  \begin{scope}[rotate=\tmpangle]
  \draw[densely dashed,#1] (#4) arc [start angle=0,delta angle=180,
  x radius=\fpeval{\tmpdistance/2} cm,y radius=\fpeval
  {\tmpdistance * (#5) / 2}cm] (#3);
  \draw[#2] (#3) arc[start angle=180,delta angle=180,x
  radius=\fpeval{\tmpdistance/2} cm,y radius=\fpeval{\tmpdistance
  * (#5) / 2}cm] (#4);
  \end{scope}
}

\begin{document}
\begin{tikzpicture}[line join=round]
  \def\radius{1}
  \def\height{4}
  \def\leftheight{1.5}
  \def\rightheight{3}
  \tkzDefPoint(-\radius,0){A}
  \tkzDefPoint(\radius,0){B}
  \tkzDefPoint(-\radius,\leftheight){C}
  \tkzDefPoint(\radius,\rightheight){D}
  \mydrawellipse{A}{B}{.2}
  \mydrawellipse[solid]{C}{D}{.18}
  \def\myshifta{.004}
  \def\myshiftb{.003}
  \tkzDefPoint(-\radius-\myshifta,0){A'}
  \tkzDefPoint(\radius+\myshiftb,0){B'}
  \tkzDefPoint(-\radius-\myshifta,\leftheight){C'}
  \tkzDefPoint(\radius+\myshiftb+.003,\rightheight-.01){D'}
  \tkzDrawSegments[line width=.4pt](A',C' B',D')
\end{tikzpicture}
\end{document}

但是,由于数学上的原因,「直接以母线上的点作为长轴顶点」的话,椭圆与圆柱的母线必不是相切的。OP提到的「这里的x radiusy radius怎么调都调不好...」正是由于此,客观来看,上面代码中的

\def\myshifta{.004}
\def\myshiftb{.003}
\tkzDefPoint(-\radius-\myshifta,0){A'}
\tkzDefPoint(\radius+\myshiftb,0){B'}
\tkzDefPoint(-\radius-\myshifta,\leftheight){C'}
\tkzDefPoint(\radius+\myshiftb+.003,\rightheight-.01){D'}
\tkzDrawSegments[line width=.4pt](A',C' B',D')

纯属气急败坏的无奈之举,局部的微调精细效果也并不够完美。

image.png

image.png

image.png

注意,本站不是「PDF分享」站

提问就要focus在真正体现你问题的关键点上,给可以体现你问题的示例代码

我帮你在原问题里补充了「最小工作示例」,希望你下次提问能自己给出

image.png


也不太难,看下原码即可:

% elegantbook.cls Line 1165
%% Example with counter
\newcounter{exam}[chapter]
\setcounter{exam}{0}
\renewcommand{\theexam}{\thechapter.\arabic{exam}}
\newenvironment{example}[1][]{
  \refstepcounter{exam}
  \par\noindent\textbf{\color{main}{\examplename} \theexam #1 }\rmfamily}{
  \par\ignorespacesafterend}

想办法把上面的设置覆盖掉即可...

\documentclass[lang=cn,11pt,twoside,openany]{elegantbook}
\geometry{paperheight=10cm}
\counterwithin{exam}{section}
\renewcommand{\theexam}{\thesection.\arabic{exam}}
\begin{document}%

\chapter{test}
\section{sec}

\begin{example}
test test test test
\end{example}

\begin{example}
    test test test test
\end{example}

\section{sec}

\begin{example}
    test test test test
\end{example}

\chapter{test}
\section{sec}

\begin{example}
    test test test test
    \end{example}
    
    \begin{example}
        test test test test
    \end{example}
    
    \section{sec}
    
    \begin{example}
        test test test test
    \end{example}
\end{document}  

image.png

注意:这样只修改了example环境,对于同样属于「示例类环境」的problemexercise环境的修改,也是类似的...留做习题...

原来的MWE已经确认为nicematrix的bug,可关注相关issues.

基于nicematrix的文档18.5中例子的一个workaround,使用了较旧的\Submatrix\Overbrace命令:

image.png

不过并不够优雅,例如下面的m_in_j居然要以两种并不对偶的方式来输入:

\documentclass{article}
\usepackage[OT1]{fontenc}
\usepackage{eulervm}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,calligraphy}
% https://tex.stackexchange.com/a/112212/322482
\makeatletter
\DeclareRobustCommand{\rvdots}{%
  \vbox{
    \baselineskip4\p@\lineskiplimit\z@
    \kern-\p@
    \hbox{.}\hbox{.}\hbox{.}
  }}
\makeatother
\usepackage{nicematrix}
\setlength{\extrarowheight}{1mm}
\begin{document}
\[ 
% a little syntax inconsisitency in this example
\begin{pNiceArray}{cccc}[margin,last-col,cell-space-limits=5pt]
    A_{11}  & A_{12}  & \cdots & A_{1s}  & \enspace m_1 \\
    A_{21}  & A_{22}  & \cdots & A_{2s}  & \enspace m_2 \\
    \rvdots & \rvdots & {}     & \rvdots & \quad \rvdots \\
    A_{r1}  & A_{r2}  & \cdots & A_{rs}  & \enspace m_r \\
    \CodeAfter
    \OverBrace[yshift=1mm]{1-1}{1-1}{n_1} 
    \OverBrace[yshift=1mm]{1-2}{1-2}{n_2} 
    \OverBrace[yshift=1mm]{1-3}{1-3}{\cdots} 
    \OverBrace[yshift=1mm]{1-4}{1-4}{n_s}
    \SubMatrix{.}{1-4}{1-4}{\rbrace}[xshift=4mm]
    \SubMatrix{.}{2-4}{2-4}{\rbrace}[xshift=4mm]
    \SubMatrix{.}{3-4}{3-4}{\rbrace}[xshift=4mm]
    \SubMatrix{.}{4-4}{4-4}{\rbrace}[xshift=4mm]
\end{pNiceArray}
\]
\end{document}

image.png

发布
问题