Sagittarius Rover
Sagittarius Rover
我要成为Typst糕手/(ㄒoㄒ)/~~

注册于 2年前

回答
267
文章
0
关注者
11

pgfplots不是太了解,follow reference link,尝试给出一个解答:

\documentclass[11pt, border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[
    colormap/jet,% change colormap style here
    scatter,
    scatter src=x,
    only marks,
    clip mode=individual,
    scatter/@pre marker code/.append code={
            \pgfkeys{/pgf/fpu=true,/pgf/fpu/output format=fixed}
            \pgfmathsetmacro\negheight{-\pgfplotspointmeta}         
            \fill [draw=black] (axis direction cs:0,0.3) rectangle (axis direction cs:\negheight,-0.3);\pgfplotsset{mark=none}
        },
    width=12cm,
    height=8cm,
    grid=both,
    ytick=data,
    xmin=0,xmax=100, 
    xlabel={Percentage (\%)},          
    ylabel={Categories},               
    % symbolic y coords={A, B, C, D, E},
    yticklabels={A, B, C, D, E},
    ytick style={draw=none},           
    %nodes near coords,
    enlarge y limits=.2,
    xtick={0, 20, 40, 60, 80, 100},
    xticklabel=\pgfmathprintnumber{\tick}\%,
  ]
    \addplot coordinates {(23,1) (45,2) (56,3) (78,4) (89,5)};
  \end{axis}
\end{tikzpicture}
\end{document}

image.png

等宽字体缺少字体├─所致。可以考虑使用\setmonofont{Consolas}修改。

image.png

我感觉你确实应该补充一下你的具体需求(比如一个完整的审稿回复应该是什么样子,你已经实现的是什么样子),我看不出这里的Reviewer为什么是一个计数器Counter,同时在你的聊天记录中似乎也有\ref的需求,但在你上述的代码中并未体现。

你上面出现结果为为Null,是因为你在调用\Rref{o4m35}时仍未经过\setStringCounter{Reviewer}{o4m35},于是为\setStringCounter{Reviewer}{NULL}定义的默认值。

事实上你把这两句放到\RTR{o4m35}之后即可。

我不知道是不是能回答你的问题。而且你的代码中\setStringCounter\getStringCounter给我的感觉就是把你所谓的"字符串"装进宏里面然后再拿出来,个人觉的目的不是很明确。

image.png

首先我有点好奇,是什么需求让你必须调节不同字体横线的粗细。此外,我认为这个问题必须提供截图的预期的粗细效果,并提供两份代码,不要让别人猜测的stix字体是如何调用的...

我目前只知道关于分数线的粗细控制...

另外根号是有左侧部分的,你的描述中只提及了横线,那左侧部分线的粗细呢?

terminal中运行latexdef \frac可得:

\frac :
\long macro:#1#2->{\begingroup #1\endgroup \over #2}

TeX命令\frac实际上是一个带编组的\over命令

In The TeXBook(Page 143), we know that there exist command \above[dim] to control the dim of the fraction bar:

image.png

除此之外,对于分数,amsmath宏包的\genfrac命令也提供了thickness用于控制粗细

image.png

关于\sqrt符号,其形状(应该)由对应的字符\radical "270370控制,是和字体强关联的。

但你也可以用盒子自己画一个(我是不会画的,因此自然是copy的):

\documentclass{article}
\def\radicando#1{%  
    \leavevmode
    \hbox{%
      \vtop{%
        \vbox{%
          \hrule height1.5pt \kern -1.2pt
          \hbox{%
            \kern 1pt \strut#1\kern 0pt
          }%
        }%
        \kern -3pt
      }%
    }
  }
\def\radice#1{\surd\kern-.25pt\radicando{\lower1.5pt\hbox{\mathstrut$#1$}}}
\begin{document}
  $\frac{1}{2}$ ${123\above2pt 456}$

  $\radice{aeiou}$ $\radice{16}$ 
\end{document}

image.png

也许有帮助。

是真的很小吗(?)那你结合图片描述一下预期的大小。

BTW,为什么要调用两次unicode-math,同时在这个mwe中ctex也和fontspec也完全没有必要调用,可删去。

image.png

应该是图书馆提供的【研究生学位论文Latex参考模板.zip】配置上有一些问题

更建议使用这个开源仓库 但使用的时候必须仔细研究其文档和学校有关规范

改正 xetex thuthesis.ins 编译得到的是thuthesis.cls文件

image.png

如果你不介意重复绘制的话,下面也许是可行的...

\documentclass[landscape]{article}
\usepackage[margin=1in,a3paper]{geometry}
\usepackage{tkz-graph}
\begin{document}
\ExplSyntaxOn
\cs_new_protected:Npn \draw_dot_diagram:n #1
{
    \pgfmathtruncatemacro{\NN}{0}
    \str_set:Nn \l_tmpa_str { #1 }
    \seq_clear:N \l_tmpa_seq
    \begin{tikzpicture}[
        line~join=round,line~cap=round,
        VertexStyle/.style = {
            shape=circle,draw,fill,
            minimum~size=5pt,
            inner~sep=0pt,
            outer~sep=0pt,
        }]
        \SetGraphUnit{2}
        \SetVertexNoLabel
        \Vertex{P\NN}
        \str_map_inline:Nn \l_tmpa_str
        {
            \pgfmathtruncatemacro{\tmp}{\NN+1}
            \str_case:nn { ##1 }
            {
                {U} {\NO(P\NN){P\tmp}}
                {D} {\SO(P\NN){P\tmp}}
                {L} {\WE(P\NN){P\tmp}}
                {R} {\EA(P\NN){P\tmp}}
            }
            \Edge(P\NN)(P\tmp)
            \pgfmathtruncatemacro{\NN}{\tmp}
        }
    \end{tikzpicture}
    \par \vspace*{3cm}
}
\draw_dot_diagram:n {RRUDRUDRR}

\draw_dot_diagram:n {RRRUDRUDRUDRR}

\draw_dot_diagram:n {RRRURUDLUUDLRDDDRRLDRURRUUDR}
\ExplSyntaxOff
\end{document}

其实重复绘制的问题应该是有优化空间的,但我下午还有课...

image.png

你的代码太长了,你希望在互联网上找人帮你看长达349行的代码?

你应该使用二分注释等方法找到真正让你"卡死"的那些部分

实际上出问题的有以下两部分:

%Line265~282
    
    \begin{tikzpicture}
        \begin{pie}[
            color={blue!20, red!20, orange!20, green!20, yellow!20},
            text=legend,
            sum=auto,
            explode=0.1,
            radius=3,
            ]
            \pie[
            text=legend]{
                10/民族舞,
                35/英文剧场,
                10/无人机,
                10/数学建模,
                35/辩论
            }
        \end{pie}
    \end{tikzpicture}

是谁教你的\begin{pie}嵌套\pie命令的(?)告诉我,是谁?你是否看过pgf-pie的文档?

image.png

需要修改成以下,只使用\pie创建饼图

    \begin{tikzpicture}
        \pie[
            color={blue!20, red!20, orange!20, green!20, yellow!20},
            text=legend,
            sum=auto,
            explode=0.1,
            radius=3,
        ]{
            10/民族舞,
            35/英文剧场,
            10/无人机,
            10/数学建模,
            35/辩论
        }
    \end{tikzpicture}

第二个问题出现在enumerate的嵌套问题上:

%Line318~347
\begin{enumerate}
        本节包含总体取值规律的估计,总体百分位数的估计,总体集中趋势估计,总体离散程度估计等内容,下面先把涉及到的一些基础知识进行梳理。
    \textbf{频率分布直方图}: 每个小矩形的面积表示数据落在该组的频率, 各小矩形的面积之和为 1.
    \textbf{百分位数}: 一组数据的第 \( p \) 百分位数是这样一个值, 它使得这组数据中至少有 \( p\% \) 的数据小于或等于这个值,且至少有 \( (100-p)\% \) 的数据大于或等于这个值,其计算步骤为:
        \begin{enumerate}
            \item 按从小到大排列原始数据;
            \item 计算 \( i=n \times p\% \), 其中 \( n \) 为样本量;
            \item 若 \( i \) 不是整数, 而大于 \( i \) 的比邻整数为 \( j \), 则第 \( p \) 百分位数为第 \( j \) 项数据; 若 \( i \) 是整数, 则第 \( p \) 百分位数为第 \( i \) 项和第 \( i+1 \) 项数据的平均数.
        \end{enumerate}
        \item \textbf{平均数}: 可反映数据的集中趋势.
        \begin{enumerate}
            \item 一组数据 \( x_1, x_2, \cdots, x_a \) 的平均数 \( \overline{x} = \frac{x_1+x_2+\cdots+x_a}{n} \).
            \item 由频率分布直方图估计样本平均数, 常用每组区间中点值代表落在该区间的数据, 若设各组区间中点为 \( x_1, x_2, \cdots, x_n \), 对应各组的频率为 \( f_1, f_2, \cdots, f_n \), 则可估计样本平均数 \( \bar{x} = \sum_{i=1}^n x_i f_i \).
        \end{enumerate}
        \item \textbf{中位数}: 可反映数据的集中趋势.
        \begin{enumerate}
            \item 对于从小到大排列的一组数据, 若数据个数为奇数, 则中位数为最中间的一个数据; 若数据个数为偶数,则中位数为中间两个数据的平均数.
            \item 由频率分布直方图估计样本中位数, 应在横轴上找到一个数, 使其左右两侧频率各占 0.5.
        \end{enumerate}
        \item \textbf{众数}: 可反映数据的集中趋势.
        \begin{enumerate}
            \item 一组数据中出现次数最多的数据即为该组数据的众数, 若有几个数据出现次数一样多, 且都比其它数据多,则它们都是众数.
            \item 由频率分布直方图估计样本众数, 取最高的小矩形区间中点即可.
        \end{enumerate}
        \item \textbf{极差}: 一组数据的最大值与最小值之差, 它可以一定程度反映数据的离散程度.
        \item \textbf{方差、标准差}: 刻画数据的离散程度. 方差、标准差越大, 数据越分散, 反之越集中.
        \begin{enumerate}
            \item 一组数据 \( x_1, x_2, \cdots, x_n \) 的方差 \( s^2 = \frac{1}{n} \sum_{i=1}^n (x_i - \bar{x})^2 = \frac{1}{n} \sum_{i=1}^n x_i^2 - \bar{x}^2 \), 方差公式的两种形式都需掌握, 计算或证明时都可能用到. 方差的算数平方根 \( s \) 即为标准差. 若数据 \( x_1, x_2, \cdots, x_n \) 有重复, 设其不重复的值为 \( y_1, y_2, \cdots, y_k \), 对应的数据个数依次为 \( f_1, f_2, \cdots, f_k \), 则 \( s^2 = \frac{1}{n} \sum_{i=1}^{k} f_i (y_i - \bar{x})^2 \).
        \end{enumerate}
    \end{enumerate}

你是否看过入门文档lshort-zh-cn(?) 在enumerate环境内必须使用\item....你这几行素在?(告诉我,为什么?)

本节包含总体取值规律的估计,总体百分位数的估计,总体集中趋势估计,总体离散程度估计等内容,下面先把涉及到的一些基础知识进行梳理。
textbf{频率分布直方图}: 每个小矩形的面积表示数据落在该组的频率, 各小矩形的面积之和为 1.
textbf{百分位数}: 一组数据的第 ( p ) 百分位数是这样一个值, 它使得这组数据中至少有 ( p% ) 的数据小于或等于这个值,且至少有 ( (100-p)% ) 的数据大于或等于这个值,其计算步骤为:

image.png

那几行前面必须加上\item

本节包含总体取值规律的估计,总体百分位数的估计,总体集中趋势估计,总体离散程度估计等内容,下面先把涉及到的一些基础知识进行梳理。
    \begin{enumerate}%%%%%%你下面这两个`\textbf`前面为什么不用????告诉我,为什么??
        \item \textbf{频率分布直方图}: 每个小矩形的面积表示数据落在该组的频率, 各小矩形的面积之和为 1.
        \item \textbf{百分位数}: 一组数据的第 \( p \) 百分位数是这样一个值, 它使得这组数据中至少有 \( p\% \) 的数据小于或等于这个值,且至少有 \( (100-p)\% \) 的数据大于或等于这个值,其计算步骤为:
        \begin{enumerate}
            \item 按从小到大排列原始数据;
            \item 计算 \( i=n \times p\% \), 其中 \( n \) 为样本量;
            \item 若 \( i \) 不是整数, 而大于 \( i \) 的比邻整数为 \( j \), 则第 \( p \) 百分位数为第 \( j \) 项数据; 若 \( i \) 是整数, 则第 \( p \) 百分位数为第 \( i \) 项和第 \( i+1 \) 项数据的平均数.
        \end{enumerate}
        %% rest ...

切忌“不懂原理的前提下四处搜罗代码”。 —— OsbertWang

效果如下:
image.png

另外你的最小工作示例还是不规范,你理应提供有问题的,让你报错的最小的那一段代码,不要期望每个人都有时间看你整篇几百行,甚至两千行文档。同时应注意内容的保密性(试卷直接发出来真的好吗...)

另附MWE定义,请仔细阅读并了解围栏代码块的用法。

下次再提问不规范试试看呢? Happy LaTeXing!

image.png

不建议使用xkeyval宏包了,latex2e kernel setup (based on l3keys)已经足够支持键值对的选项。

从你的代码来说,只要删除testclass.cls\ExecuteOptionsX{text={key1=12345, key2=abcde}}的命令即可,\ExecuteOptionsX用于声明默认选项,不应该放在\ProcessOptionsX之后。但即使如此做,虽然可以传递option,但仍会导致出现LaTeX Warning: Unused global option(s):[text={key1=67890}]的提示,这也是不推荐使用的原因。

一个简陋的办法是在\begin{document}后使用\setlength{\oddsidemargin}{-3pt}(不一定准确,我的pdf-viewer没有标尺)微调。

个人认为你这个问题的本质是revtex4-2的双栏布局和单栏的figure之间的冲突。当你使用article文档类时代码并没有什么问题;而使用revtex4-2出错,说明是revtex4-2的问题。好的问题题目会方便其他人检索到。

\caption*用法说明

image.png

要想引用必须有内容
(我不是太理解为什么你一定要藏起来subcaption的(a)(b)(c)(d)?这样读者很难快速定位到Fig.4(d)和Fig.8(e)指的是哪个吧)

https://www.latexstudio.net/index/details/index/mid/3922.html

源代码中的 \onecolumngrid\twocolumngrid 进行切换 (但我不是太懂revtex4-2...)

\documentclass[reprint,aps,amsmath,amssymb,]{revtex4-2}
\usepackage{graphicx}% Include figure files
\usepackage{subcaption} % For subfigure
\usepackage{float}
\usepackage{lipsum}
\usepackage{hyperref}% add hypertext capabilities
\begin{document}

\lipsum[1-9]

\onecolumngrid

\begin{figure*}[htbp]
    \centering
    % First row of images (subfigure 1 and subfigure 2)
    \begin{subfigure}[b]{0.45\textwidth}
        \centering
        \includegraphics[width=\textwidth, keepaspectratio]{example-image-a}
        \caption{}\label{a}
    \end{subfigure}%
    \hspace{0.1cm}
    \begin{subfigure}[b]{0.45\textwidth}
        \centering
        \includegraphics[width=\textwidth, keepaspectratio]{example-image-b}
        \caption{}\label{b}
    \end{subfigure}
    % Second row of images (subfigure 3 and subfigure 4)
    \begin{subfigure}[b]{0.45\textwidth}
        \centering
        \includegraphics[width=\textwidth, keepaspectratio]{example-image-c}
        \caption{}\label{c}
    \end{subfigure}%
    \hspace{0.1cm}
    \begin{subfigure}[b]{0.45\textwidth}
        \centering
        \includegraphics[width=\textwidth, keepaspectratio]{example-image}
        \caption{}\label{d}
    \end{subfigure}
    \caption{Overall caption for the entire figure.}
    \label{fig2:mainfig}
\end{figure*}

\twocolumngrid

In Fig.~\ref{fig2:mainfig}~(\ref{a}), (\ref{b}), and (\ref{c}), we show ...

\lipsum[10-12]

\end{document}

image.png

我不太知道你的图片是如何实现的,我只提供昨晚群里讨论出来的一种代码实现(应该算是回答了你的问题标题)。

By S老师@u79794:

图片中是行内公式,在enumerate环境中使用,并且使用t(top)参数,即:$\begin{align}[t] … \end{align}$,然后再使用类似dotfill那种评分的东西,exam-zh模板有相应的模块

我借鉴了李清和xdyy用于exam-zh的方法,一个实现和效果如下:

\documentclass[12pt]{ctexart}
\usepackage[a4paper,showframe]{geometry}
\usepackage{amsmath,mathtools}
\usepackage{zref-savepos}
\makeatletter
\ExplSyntaxOn
\zref@require@unique

\NewDocumentCommand { \score } { O{} m }
  {
    \mode_if_math:TF
      { \@@_math_cdotfill:n { #2 \text { ~ 分 } } }
      { \__examzh_cdotfill: #2 分 }
    \mode_if_math:F
      {
        \par \noindent \ignorespaces
      }
  }
% 仿照 latex.ltx, line 651 的 \dotfill
\cs_new:Npn \__examzh_cdotfill:
  {
    \mode_leave_vertical:
    \cleaders \hb@xt@ .44em {\hss $\cdot$ \hss} \hfill
    \kern\z@
  }

\cs_new_protected:Npn \@@_math_cdotfill:n #1
  {
    \stepcounter { zref@unique }
    \hbox_overlap_right:n
      {
        \zsaveposx { \thezref@unique L }
        \zref@ifrefundefined { \thezref@unique R }
          { }
          {
            \cleaders
              \hbox_to_wd:nn { .44em } { \hss $\cdot$ \hss }
              \skip_horizontal:n
                {
                    \zposx { \thezref@unique R } sp
                  - \zposx { \thezref@unique L } sp
                }
          }
      }
    \tag * { \zsaveposx { \thezref@unique R } #1 }
  }

\ExplSyntaxOff
\makeatother

\begin{document}

    \begin{flalign*}
        & a^2 +b^2+c^2 = d^2&\\
        & \sum_{n=1}^\infty \frac{1}{n^2}=\frac{\pi^2}{6}&\\
    \end{flalign*}

    \begin{flalign*}
        &\frac{x_{n + 1}}{x_n} = \sqrt{\frac{2}{x_n^2} + \frac{1}{x_n}} > \sqrt{\frac{2}{2^2} + \frac{1}{2}} = 1,\score{2}&&\\
        &a^2+b^2+c^2=d^2,\score{4}&&\\
        &\sum_{n=1}^\infty \frac{1}{n^2}=\frac{\pi^2}{6},\score{8}&&
    \end{flalign*}

\end{document}

image.png

有几个问题

  • 卡住运行不了很不严谨,请提供命令行的报错信息
  • table,tabularcaption还是没弄明白 reference 体会一下插入-编号-浮动的过程
  • 请查看围栏代码块的用法,并使用完善问题的功能

效果对比:
image.png

\documentclass[a4paper,11pt]{article}
\usepackage{amsmath}
\usepackage{ctex}
\begin{document}
\section{Start}
\listoftables
\begin{table}
\begin{tabular}{l@{阿巴巴}|c|c|r}
    \hline
    1 & 2 & 3 & 4 \\
    \hline
    2 &2&3&4 \\
    \hline
    3&2&3&4\\
    \hline
\end{tabular}
\caption[这是一个短标题]{这是一个长查查尝长长惆怅长岑长惆怅长岑长擦擦擦擦擦擦擦擦擦擦擦擦标题}
\end{table}

\begin{table}
\begin{tabular}{l@{阿巴巴}|c|c|r}
    \hline
    1&2&3&4 \\
    \hline
    2 &2&3&4 \\
    \hline
    3&2&3&4\\
    \hline
\end{tabular}
\caption[这是一个短标题2]{这是一个长查查尝长长惆怅长岑长惆怅长岑长擦擦擦擦擦擦擦擦擦擦擦擦标题}
\end{table}
\begin{table}
\begin{tabular}{l@{阿巴巴}|c|c|r}
    \hline
    1 & 2 & 3 & 4 \\
    \hline
    2 &2&3&4 \\
    \hline
    3&2&3&4\\
    \hline
\end{tabular}
\caption[这是一个短标题3]{这是一个长查查尝长长惆怅长岑长惆怅长岑长擦擦擦擦擦擦擦擦擦擦擦擦标题}
\end{table}
\end{document}

image.png

彩蛋:请思考为何\listoftable出现在这个位置?什么是浮动体?

我来给一个非常不成熟的做法。直接搬!
my related question and discussion here~

我的做法是,将l3doc.cls复制一份,将其后缀名修改为l3doc.sty,之后注释去Line402的\LoadClass{article}语句后,将l3doc.sty置于工作目录下即正常使用\usepackage{l3doc}.

当然上述的操作是有缺陷的,例如和texmf树中的l3doc官方文档类可能存在一定的命名<namespace>冲突,cfr在上面的链接中指出也是建议修改.sty名称的(例如将l3doc改为mydoc),但在l3doc.cls中存在较多以l3doc为类名称的\message,此处我并没有做修改。

当将修改过后的l3doc.sty文档放到工作目录后,可以得到:

\documentclass{book}
\usepackage{l3doc}
\usepackage{lipsum}
\begin{document}

\cs{lipsum} some text \cmd{zhlipsum} some text \cs{tl_if_empty:NTF} \meta{tl~var} \Arg{true code} \Arg{false code} some text you can use \cmd{l3doc} like that

\lipsum[1]

\begin{function}{\package_function_one:N, \package_function_two:n}
    \begin{syntax}
    \cs{package_function_one:N} \meta{cs}
    \cs{package_function_two:n} \marg{Argument}
    \end{syntax}
    Descriptive~text~here~...\lipsum[2]
\end{function}

\vspace*{2ex}
\lipsum[3]

\end{document}

image.png

当然,如果你的目标是all stuffs in l3doc,上面的做法是可行的,你可以使用\cs,syntax,function等所有命令;但是如果你的目标仅仅是提取出function,上面的不完美做法会存在大量的冗余定义,并不优雅。对于后者的需求需要对l3doc.cls的代码有更深的认识,之后可以从\DeclareDocumentEnvironment { function } 开始考虑"逆向工程",提取出和此有关的所有代码(但我不会latex3.....短时间内也没空....)另附MWE压缩文件。

l3doc-MWE.zip

发布
问题