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

注册于 3年前

回答
434
文章
0
关注者
15

与TL的版本无关。

此事在此亦有记载。

comment宏包的文档中我们可以看到:

image.png

这要求在被comment的环境内不能有任何前方的空格和后方的内容。

image.png

上图中\begin{solution}前有8个空格...

注意LaTeX不是一门可以随意空行、空格的语言,每一个字符,甚至是注释符号%是否存在、是否用在正确的位置都可能影响结果。

下面的代码去掉前导空格之后即可以正确工作...

\documentclass{ctexart}
\usepackage{zhlipsum}

\newenvironment{solution}{\par
    \textbf{答案}\quad
}{\par}

\usepackage{comment}
\excludecomment{solution}  % 添加这两句话将注释掉所有的`solution`环境

\begin{document}
    
    \begin{enumerate}
        \item 第一题
\begin{solution}
    \zhlipsum[1]
\end{solution}
        \item 第二题
\begin{solution}
    \zhlipsum[2]
\end{solution}
    \end{enumerate}
    
\end{document}

image.png

当有多个问题时,请分点描述。

如何选择合适的 LaTeX 编辑器?

Install-Guide-zh-cn的5.6节

image.png

TeXStudio样子不够美观,对我来说是在用,但估计很多的技巧我都不会;请问下大佬们有没有这方面使用的资料可以引导我一下。

不要为了学技巧而学技巧。你可以具体提问是否有一些很麻烦的操作,并询问在某个编辑器中是否有高效的办法。非要技巧的话...当然是官方文档,介绍了TXS的所有功能。

BTW,关于配置也只需要下面这段在Install-Guide的附录B.4的配置即可.

image.png
image.png

作为新手,直接copy即可。对于这种详细配置的方法,没有、也不应该期待有详细的中文介绍如何配置的文章,所有的配置都在LaTeXWorkshop的wiki中,要想真正得其法,只能读文档。

我一直也想像知乎上面那些大佬们设置片段,但不得其法。

要想设置代码片段「a.k.a. "snippets"」,这是vscode作为编辑器提供的功能。可以参见这里的官方介绍。另外你也可以考虑借助大语言模型尝试给你正确的snippets配置到相关的例如latex.json文件中。同样的,也有一些网站专门帮助生成snippets片段。

image.png

另外,在texstudio中,Ctrl+B,会把文字加上加粗的标记,在 VS Code 有这样的操作方法么?

所有快捷键和效果可见这个链接里的cheatsheet

但很遗憾,LaTeXWorkShop没有重载这个快捷键,但你可以通过修改keybindings.json自行配置。

image.png

BTW, LaTeXworkshop插件提供了用来加粗的方式:

image.png

需要先按「Ctrl+I」再按「Ctrl+B」....当然你都可以自己改,但要注意和现有的快捷键有冲突要处理....

另外 VS Code 编辑 TeX,有没有学习的资料

...ummm

可以在这里写一篇...


Table of Contents

  • 如何在vscode中用命令行编译
  • 如何用vscode编辑代码
  • 如何利用「LaTeXWorkshop」的功能快速编译

在vscode中用命令行编译:

首先要认识到的是,无论使用什么工具,本质上都是用命令行编译。

  • 右键「在终端中打开」后输入pdflatex也好
  • 在vscode中用终端编译也好
  • 在texstudio中点击绿色三角也好

本质都是自动或手动在命令行输入对应的编译命令

  • 首先新建一个.tex文件,输入比如说"你好世界"
  • 按快捷键「Ctrl+(反引号)」呼出终端,选择"终端"
  • 输入编译命令例如「latexmk -pdfxe mwe.tex」回车即可,同时终端会显示编译的日志

image.png

在vscode中编辑...其实也没啥可说的

就是给你一个页面可以往里面输入代码。

需要注意的的是,只有当你新建了.tex文件,左侧才会出现对应的"TEX"图标。

image.png

利用LW的功能(绿色三角)编译

image.png

  • 左侧的编译方式列表为你在settings.json里配置的recipe键的值,应该根据代码选择合适的编译方式
  • 左侧还有快捷输入某些符号的功能,点击即可插入
  • 右上角的「放大镜图标」可以预览PDF(且不会像WPS一样占用,这点好评)
  • 右上角的「绿色三角」默认情况下意味着你的第一个recipe的编译方法

点击绿色三角,编译就会按照对应的方式(注意,这跟前面在命令行输入代码实际上是完全相同的)自动进行,可在左下角查看状态,在下方的「Problems」面板查看报错信息。

image.png

0.精通lshort-zh-cn,没有基础和一定的debug能力很难做开发

1.找几个同类的「论文模板」作为参照

2.分析其大致需要哪些模块的功能,使用了哪些宏包

3.精读这些宏包的文档并进一步看懂这些模板的源码

4.根据贵校的论文格式规范做修改,完善模板

notes:不用过多涉及plain-tex,是否需要latex3要看个人选择.

It seemly consists two questions:

  • define a custom counter for Exercises that is tied to the current chapter
  • create a separate List of Exercises (similar to a Table of Contents)

Noted that, one post should just focused on just one core point. BTW, you'd better provide an MWE, which make it convenient for users on the site to test and start with.


For the first one, you may have a look at chngcntr package(which has been in the 2e-kernel)

For the second one, maybe you can give a glance on tocbasic package in koma-script bundle.


补充:

此处用tocbasic似乎不是非常合适,因为这需要exercise成为浮动体。

最好是模仿\section里的\@starttoc功能做类似的实现。

先给一个workaround:

\documentclass{beamer}
\usepackage{lipsum}
\usepackage{setspace}
\newenvironment{myframe}[2][1.5]
   {%
        \begin{frame}[#2]
        \setstretch{#1}
   }%
   {%
        \end{frame}
   }%
\begin{document}
    \begin{frame}
        \lipsum[1][1-5]
    \end{frame}

    \begin{myframe}[3]{t}
        \lipsum[1][1-5]
    \end{myframe}

   \begin{myframe}[2]{c}
       \lipsum[1][1-5]
   \end{myframe}

    \begin{frame}
           \lipsum[1][1-5]
    \end{frame}
\end{document}

image.png


同时它要接受一些参数,并将其传递给frame环境,考虑到frame环境是一个脆弱的环境,我的尝试总是失败。

当提到「总是失败」时,最好贴一下报错信息,这样更容易让这个问题被别人搜索到,也更完整。下面看我的几个探索。

探索一:

你的问题和参数有关吗?并不是。下面的例子中,frame没问题;但myframe有问题。

\documentclass{beamer}
\usepackage{lipsum}
\usepackage{setspace}
\newenvironment{myframe}
   {%
        \begin{frame}
        \begin{spacing}{2}
   }%
   {%
        \end{spacing}
        \end{frame}
   }%
\begin{document}
    \begin{frame}
        \begin{spacing}{2}
        \lipsum[1][1-5]
        \end{spacing}
    \end{frame}

    \begin{myframe}
        \lipsum[1][1-5]
    \end{myframe}
\end{document}

报错信息:

! File ended while scanning use of \beamer@collect@@body.
<inserted text>
                \par
<*> mwe

?

探索二:

这个问题和beamer提供的frame环境有关吗?换成minipage看看(?)

\documentclass{beamer}
\usepackage{lipsum}
\usepackage{setspace}
\newenvironment{myframe}
   {%
        \begin{minipage}{\textwidth}
        \begin{spacing}{2}
   }%
   {%
        \end{spacing}
        \end{minipage}
   }%
\begin{document}
    \begin{minipage}{\textwidth}
        \begin{spacing}{2}
        \lipsum[1][1-5]
        \end{spacing}
    \end{minipage}

    \begin{myframe}
        \lipsum[1][1-5]
    \end{myframe}
\end{document}

image.png

并没有报错,所以这是"非常独特的",当且仅当同时使用frame内嵌spacing才会触发错误。

最后从这个链接来看,用\setstretch可以规避这一问题,所以有了workaround...

最后的最后,不要忘记问题并没有真正解决...


翻到一个神奇的结论:

由于beamer实在是太坏了。egreg说:

Moral of the story
Don't use setspace with beamer😀.

感谢@u101077 老师提供的方案,调整\multirow的行数即可。

\documentclass[fontset=fandol]{ctexart}
\usepackage{array}
\usepackage{multirow}
\usepackage{amsmath,amsfonts}
\usepackage{makecell}

\begin{document}
\begin{tabular}{|c|c|c|}
\hline
\textbf{条件} & \textbf{方程} & \textbf{说明} \\ \hline
\multirow{2}{*}{圆心在原点} & $x^2+y^2=r^2$ & $a=b=0$ \\ \cline{2-3}
 & $x^2+y^2+F=0$ & $D=E=0$ \\ \hline
\multirow{2}{*}{圆过原点} & $(x-a)^2+(y-b)^2=a^2+b^2$ & $a^2+b^2=r^2$ \\ \cline{2-3}
 & $x^2+y^2+Dx+Ey=0$ & $F=0$ \\ \hline
\multirow{2}{*}{圆心在$x$轴上} & $(x-a)^2+y^2=r^2$ & $b=0$ \\ \cline{2-3}
 & $x^2+y^2+Dx+F=0$ & $E=0$ \\ \hline
\multirow{2}{*}{圆心在$y$轴上} & $x^2+(y-b)^2=r^2$ & $a=0$ \\ \cline{2-3}
 & $x^2+y^2+Ey+F=0$ & $D=0$ \\ \hline
\multirow{3}{*}{圆与$x$轴相切} & $(x-a)^2+(y-b)^2=b^2$ & $|b|=r$ \\ \cline{2-3}
 & \makecell{$x^2+y^2+Dx+Ey+F=0$\\$(E\neq 0,D^2-4F=0)$} & $E\neq 0,D^2-4F=0$ \\ \hline
\multirow{3}{*}{圆与$y$轴相切} & $(x-a)^2+(y-b)^2=a^2$ & $|a|=r$ \\ \cline{2-3}
 & \makecell{$x^2+y^2+Dx+Ey+F=0$\\$(D\neq 0,E^2-4F=0)$} & $D\neq 0,E^2-4F=0$ \\ \hline
 \multirow{2}{*}{圆心在$x$轴上且圆过原点} & $(x-a)^2+y^2=a^2$ & $|a|=r,b=0$ \\ \cline{2-3}
 & $x^2+y^2+Dx=0$ & $E=F=0,D\neq 0$ \\ \hline
\multirow{2}{*}{圆心在$y$轴上且圆过原点} & $x^2+(y-b)^2=b^2$ & $a=0,|b|=r$ \\ \cline{2-3}
 & $x^2+y^2+Ey=0$ & $D=F=0,E\neq 0$ \\ \hline
\multirow{3}{*}{圆与$x,y$轴都相切} & \makecell{$(x-a)^2+(y-b)^2=a^2$\\$(|a|=|b|\neq 0)$} & $|a|=|b|=r$ \\ \cline{2-3}
 & \makecell{$x^2+y^2+Dx+Ey+F=0$\\$(|D|=|E|\neq 0)$} & $D^2=E^2=4F$ \\ \hline
\end{tabular}

\end{document}

image.png

不过我不确定若右侧内容中存在\dfrac,或者插入图片等「高度不是行数的整数倍」的情况是否都具有良好的可拓展性...是不是总是能找到这个合适的\multirow{<nrow>}...

\documentclass[fontset=fandol]{ctexart}
\usepackage{array}
\usepackage{multirow}
\usepackage{amsmath,amsfonts}
\usepackage{makecell}
\usepackage{graphicx}
\begin{document}
\begin{tabular}{|c|c|c|}
\hline
\textbf{条件} & \textbf{方程} & \textbf{说明} \\ \hline
\multirow{2}{*}{圆心在原点} & $x^2+y^2=r^2$ & $a=b=0$ \\ \cline{2-3}
 & $x^2+y^2+F=0$ & $D=E=0$ \\ \hline
\multirow{3}{*}{圆与$x,y$轴都相切} & \makecell{$(x-a)^2+(y-b)^2=a^2$\\$(|a|=|b|\neq 0)$} & $|a|=|b|=r$ \\ \cline{2-3}
 & \makecell{$x^2+y^2+Dx+Ey+F=0$\\$(|D|=|E|\neq 0)$} & $D^2=E^2=4F$ \\ \hline
\multirow{3}{*}{圆与$x,y$轴都相切} & \makecell{$\dfrac{1}{2}(x-a)^2+(y-b)^2=a^2$\\$(|a|=|b|\neq \dfrac{1}{2})$} & $|a|=|b|=r$ \\ \cline{2-3}
 & \makecell{$x^2+y^2+\dfrac{4}{5}Dx+Ey+F=0$\\$(|D|=|E|\neq 0)$} & $D^2=E^2=F$ \\ \hline
\multirow{7}{*}{圆与$x,y$轴都相切} & \makecell{$\dfrac{1}{2}(x-a)^2+(y-b)^2=a^2$\\$(|a|=|b|\neq \dfrac{1}{2})$} & $|a|=|b|=r$ \\ \cline{2-3}
 & \makecell{$x^2+y^2+\dfrac{4}{5}Dx+Ey+F=0$\\$(|D|=|E|\neq 0)$} &\includegraphics[width=4cm]{example-image}\\\hline
\end{tabular}
\end{document}

image.png

直观上一种可行的办法也许是把多余的行一分为二...

image.png

但这样的坏处也是显然的:

  • 无法吃到cell{even}{1} = {r=2}{m}这样的糖的福利
  • 其他位置要多写好几个cell合并...

为了吃上mode=math的红利,而放弃了其他代码的简洁性,这也是我不太能接受的...

LaTeX插入.eps图片的逻辑是:

  • 内部使用epstopdf.exe先将.eps转为.pdf
  • 然后按照正常插入.pdf的方法实现

从报错信息来看:

Package pdftex.def: File `1-eps-converted-to.pdf' not found: using draft setting.

可能你需要检查一下在wslepstopdf程序是否存在,是否可以直接运行.

一个基于stackengine的方案为:

\documentclass{article}
\usepackage{centernot}
\usepackage{stackengine}
\usepackage{amsmath,amssymb}
\newcommand*{\notLongrightarrow}{\centernot{\Longrightarrow}}
\newcommand*{\notLongleftarrow}{\centernot{\Longleftarrow}}
\newcommand*{\onlyRtoL}[1][-2pt]{\mathrel{\stackanchor[#1]{$\Longleftarrow$}{$\notLongrightarrow$}}}
\begin{document}

\[A \Longrightarrow B \notLongrightarrow C\]

\[A \Longleftarrow B \notLongleftarrow C\]

\[A \mathrel{\stackanchor{$\Longleftarrow$}{$\Longrightarrow$}} B \]

\[A \mathrel{\stackanchor[4pt]{$\notLongleftarrow$}{$\Longrightarrow$}} B \]

\[ 
\lim_{n\to\infty} y_n \quad \onlyRtoL[5pt] \quad |y_1|+|y_2|+\cdots+|y_n|\leq M\]

\end{document}

image.png

这是普通的行间距。对于中文,会被ctex通过默认的scheme=chinese设置为1.3倍...

如果你确实希望缩短全文的中文行距,可以用:scheme=plain...

image.png

同时enumitem提供了noitemsep最好不要手动以不准确的方式微调参数:

image.png

\documentclass[
        a4paper,11pt,
        scheme=plain% 不修该行距为1.3倍
    ]{ctexart}
    \usepackage{enumitem}
    \usepackage{zhlipsum}
    \begin{document}
        \begin{enumerate}[label={\Alph*.}]%
        \item 有非法关键字?有非法关键字?有非法关键字?有非法关键字?有非法关键字?有非法关键字?
        \item 有非法关键字?有非法关键字?有非法关键字?有非法关键字?有非法关键字?有非法关键字?
        \item 有非法关键字?有非法关键字?有非法关键字?有非法关键字?有非法关键字?有非法关键字?
        \end{enumerate}

        \bigskip

        \begin{enumerate}[label={\Alph*.},noitemsep]%
        \item 有非法关键字?有非法关键字?有非法关键字?有非法关键字?有非法关键字?有非法关键字?
        \item 有非法关键字?有非法关键字?有非法关键字?有非法关键字?有非法关键字?有非法关键字?
        \item 有非法关键字?有非法关键字?有非法关键字?有非法关键字?有非法关键字?有非法关键字?
        \end{enumerate}

        \bigskip

        下面这个中文段落行距太窄并不好看...

        \zhlipsum[2]
    \end{document}

image.png


Edited:中西文对比

\documentclass[a4paper,11pt]{article}
\usepackage{enumitem}
\usepackage{lipsum}
\begin{document}
\begin{enumerate}[label={\Alph*.}]%
 \item \lipsum[1][1-3]
 \item \lipsum[1][1-3]
 \item \lipsum[1][1-3]
 \item \lipsum[1][1-3]
 \end{enumerate}

 \bigskip

\begin{enumerate}[label={\Alph*.},noitemsep]%
 \item \lipsum[1][1-3]
 \item \lipsum[1][1-3]
 \item \lipsum[1][1-3]
 \item \lipsum[1][1-3]
 \end{enumerate}
\end{document}

image.png

Edited Again:

\documentclass[a4paper,11pt]{ctexart}
\usepackage{enumitem}
\setlength{\parindent}{0pt}
\begin{document}
    如果既想要正文的行距保持正常,又想要只在\texttt{enumerate}环境内让行距变得紧凑...

    我能吞下玻璃而不伤身体
    我能吞下玻璃而不伤身体
    我能吞下玻璃而不伤身体
    我能吞下玻璃而不伤身体
    我能吞下玻璃而不伤身体

    \begin{enumerate}[%
        itemsep=-1.8mm,label={\Alph*.},
        before=\linespread{1.0}\selectfont
        ]
        \item 我能吞下玻璃而不伤身体我能吞下玻璃而不伤身体我能吞下玻璃而不伤身体
        \item 我能吞下玻璃而不伤身体我能吞下玻璃而不伤身体我能吞下玻璃而不伤身体
        \item 我能吞下玻璃而不伤身体我能吞下玻璃而不伤身体我能吞下玻璃而不伤身体
    \end{enumerate}

    我能吞下玻璃而不伤身体
    我能吞下玻璃而不伤身体
    我能吞下玻璃而不伤身体
    我能吞下玻璃而不伤身体
    我能吞下玻璃而不伤身体

    不过这是不太好的...因为行文的行距就不一致了,是不太好的排版...

\end{document}

image.png

maybe related to \quotation:

如果先暂时不看abstract宏包

\setlength{\absleftindent}{0pt} %取消左边距
\setlength{\absrightindent}{0pt} %取消右边距
\renewcommand{\abstracttextfont}{\normalsize} %确保摘要环境内外字号一致

的设置...

% line 366~408 article.cls
\if@titlepage
    ....
\else
  \newenvironment{abstract}{%
      \if@twocolumn
        \section*{\abstractname}%
      \else
        \small
        \begin{center}%
          {\bfseries \abstractname\vspace{-.5em}\vspace{\z@}}%
        \end{center}%
        \quotation
      \fi}
      {\if@twocolumn\else\endquotation\fi}
\fi
...
\newenvironment{quotation}
               {\list{}{\listparindent 1.5em%
                        \itemindent    \listparindent
                        \rightmargin   \leftmargin
                        \parsep        \z@ \@plus\p@}%
                \item\relax}
               {\endlist}

其中在abstarct中的首行缩进名为\listparindent 1.5em.可见下例。

\documentclass{article}
\usepackage{showframe}
\usepackage{lipsum}
\parindent=0em

\makeatletter
  \renewenvironment{abstract}{%
  \if@twocolumn
    \section*{\abstractname}%
  \else
    \small
    \begin{center}%
      {\bfseries \abstractname\vspace{-.5em}\vspace{\z@}}%
    \end{center}%
    \quotation
  \fi}
  {\if@twocolumn\else\endquotation\fi}

\renewenvironment{quotation}
   {\list{}{%
            \listparindent 1.5em% %<-important here
            \itemindent    \listparindent
            \rightmargin   \leftmargin
            \parsep        \z@ \@plus\p@}%
    \item\relax}
   {\endlist}

\makeatother

\begin{document}

\lipsum[2]

\begin{abstract}

\lipsum[2]

\end{abstract}

\lipsum[2]

\end{document}

image.png


哇...根源貌似找到了:abstract环境内又嵌套了quotation环境,而quotation环境内主动将itemindent的值设为了\listparindent

对的。

那请问怎么少改动的“使内的与外的一致”呢,从局部优先的特征来看只能重定义整个quotation环境了吗...

我感觉重定义quotation也并不太好,这可能影响正文中正常使用quotation环境。

「怎么少改动的“使内的与外的一致”呢?」按我理解的需求是:

  • abstract内的首行间距与\parindent一致
  • 不影响正文中quotation环境的正常使用

我感觉把\quotation复制一份使用\parindent的版本\myquotation专门用于abstarct也许会更好(?)例如这样:

\documentclass{article}
\usepackage{showframe}
\usepackage{lipsum}

\usepackage{etoolbox}
\makeatletter
\NewCommandCopy{\myquotation}{\quotation}
\renewcommand\myquotation{%
    \list{}{%\listparindent 1.5em%
            \itemindent    \parindent %\listparindent
            \rightmargin   \leftmargin
            \parsep        \z@ \@plus\p@}%
        \item\relax
}
\patchcmd{\abstract}{\quotation}{\myquotation}{}{}
\makeatother

\parindent=0em

\begin{document}

\begin{quotation}
    \lipsum[2][1-5]
\end{quotation}

\lipsum[2][1-5]

\begin{abstract}

\lipsum[2][1-5]

\begin{quotation}
    \lipsum[2][1-5]
\end{quotation}

\end{abstract}

\lipsum[2]

\begin{quotation}
    \lipsum[2][1-5]
\end{quotation}

\end{document}

image.png

此时对于正文段落的间距\parindent似乎是一致了,但对于enumerate似乎仍有问题...

\documentclass{article}
\usepackage{showframe}
\usepackage{lipsum}
\usepackage{abstract}
\setlength{\absleftindent}{0pt}
\setlength{\absrightindent}{0pt}
\renewcommand{\abstracttextfont}{\normalsize}
\usepackage{etoolbox}
\makeatletter
\NewCommandCopy{\myquotation}{\quotation}
\renewcommand\myquotation{%
    \list{}{%\listparindent 1.5em%
            \itemindent    \parindent%\listparindent
            \rightmargin   \leftmargin
            \parsep        \z@ \@plus\p@}%
        \item\relax
}
\patchcmd{\abstract}{\quotation}{\myquotation}{}{}
\makeatother

\parindent=4em

\begin{document}

\lipsum[2][1-5]

\begin{abstract}

\lipsum[2][1-5]

\begin{enumerate}
\item this is text. this is text. this is text. this is text. this is text. this is text. this is text. this is text. 
\item this is text. this is text. this is text. this is text. this is text. this is text. this is text. this is text. 
\end{enumerate}

\end{abstract}

\lipsum[2]

\begin{enumerate}
\item this is text. this is text. this is text. this is text. this is text. this is text. this is text. this is text. 
\item this is text. this is text. this is text. this is text. this is text. this is text. this is text. this is text. 
\end{enumerate}

\end{document}

image.png

沉默...


把评论区中的测试代码搬到我们的目标「希望abstract环境」和「正文环境」保持一致,注意quotation环境中实际上就是一个\list,既然我们想要和正文一致,不妨直接(非常暴力地)把\myquotation置为空,这样似乎就不会受到:

\listparindent 1.5em%
\itemindent    \listparindent
\rightmargin   \leftmargin
\parsep        \z@ \@plus\p@

的影响了...(因为原先abstract内部就借用了quotation内部也借用了\list,所以在abstract内部用enumerate实际上是"list in list"...)

这样的话,也不需要abstract宏包调整字号了,直接从底层自定义想要的abstract环境...(嗯我也不知道好不好...)

\documentclass{article}
\usepackage{showframe}
\usepackage{lipsum}
%% 不用 abstract 宏包,自力更生吧...
\usepackage{etoolbox}
\patchcmd{\abstract}{\small}{}{}{}
\patchcmd{\abstract}{\quotation}{}{}{}
\patchcmd{\endabstract}{\endquotation}{}{}{}

\newcommand\txt{This is some txt txt txt txt txt txt. }
\newcommand\mytxt{\txt\txt\txt\txt\txt\txt}
\newcommand*\printvalue[1]{\texttt{\string #1} : \the #1}

\parindent=2em % 为了适应「10.」的两位数缩进稍微调大了...
\usepackage{enumitem}
\setlist{
    align=left,
    leftmargin=0pt,
    itemindent=\parindent,
    labelindent=0pt,
    labelwidth=!,
}

\begin{document}

\makeatletter
\texttt{\meaning\abstract}

\texttt{\meaning\endabstract}
\makeatother

\lipsum[2][1-5]

\begin{abstract}

\lipsum[2][1-5]

\begin{enumerate}[start=8]
\item \printvalue\leftmargin
\item \printvalue\itemindent
\item \printvalue\labelsep
\item \printvalue\labelwidth
\item \printvalue\labelindent
\item \mytxt
\end{enumerate}

\end{abstract}

\lipsum[2]

\begin{enumerate}[start=8]
\item \printvalue\leftmargin
\item \printvalue\itemindent
\item \printvalue\labelsep
\item \printvalue\labelwidth
\item \printvalue\labelindent
\item \mytxt 
\end{enumerate}

\end{document}

image.png

1.mwea在这里起的作用是?

2.是不是可以理解成,你希望:

  • 假定在一些操作后计数器初始值cnt=5
  • \cmd*带星号,不会自动清零(resume),这将导致cnt=6
  • \cmd*带星号,同样不会自动清零(resume),这将导致cnt=7
  • \cmd不带星号,自动清零,这将导致cnt=0清零之后自增cnt=1
  • \cmd*带星号,不会自动清零(resume),这将导致cnt=2 ?

3.该问题如果与beamer无关,则mwe最好用article或者book


version 1

\documentclass{beamer}
\newif\ifresume %<- add newif condition
\resumefalse
\newcommand{\separateline}[1]{%
    \hrulefill\ $\downarrow$ #1 $\downarrow$\ \hrulefill%
}
\newcounter{mwea}
\newcounter{mweb}
\newcommand{\mwea}{%
    \stepcounter{mwea}%
    \ifresume
        \setcounter{mweb}{1}%
    \fi
    cnt mwea's value is \themwea. \par%
}
\newcommand{\mweb}{%
    \stepcounter{mweb}%
    cnt mweb's value is \themweb. \par%
}
\begin{document}
\frame{
    
    \ttfamily\small

    \separateline{first layer}
    
    \mwea \mweb \mweb \mweb 

    \separateline{second layer}

    \mwea \mweb \mweb \mweb  

    \separateline{third layer}
    
    \mwea \mweb \mweb \mweb  

    \resumetrue%<- change the condition
    \separateline{fourth layer}

    \mwea \mweb \mweb \mweb 

}
\end{document}

image.png

version 2

\documentclass{beamer}
\newcommand{\separateline}[1]{%
    \hrulefill\ $\downarrow$ #1 $\downarrow$\ \hrulefill%
}
\newcounter{mwea}
\newcounter{mweb}
\NewDocumentCommand{\mwea}{s}{%
    \stepcounter{mwea}%
    \IfBooleanF{#1}{\setcounter{mweb}{1}}%
    cnt mwea's value is \themwea. \par%
}
\newcommand{\mweb}{%
    \stepcounter{mweb}%
    cnt mweb's value is \themweb. \par%
}
\begin{document}
\frame{
    \ttfamily\small

    \separateline{first layer}
    
    \mwea* \mweb \mweb \mweb 

    \separateline{second layer}

    \mwea* \mweb \mweb \mweb  

    \separateline{third layer}
    
    \mwea \mweb \mweb \mweb  %<- clear the mweb here

    \separateline{fourth layer}

    \mwea* \mweb \mweb \mweb 
}
\end{document}

image.png

不要重复提问。

请删除另一个问题。

你可以@超管 @u30 查看。

可以试试luadraw宏包:

当然,这需要手动安装,也需要lualatex

如果要画的函数没有简单的极坐标公式的话,这种方式可能是最具有拓展性的。

\documentclass[border=4pt]{standalone}
\usepackage{luadraw}
\begin{document}
\begin{luadraw}{name=implicit_function}
    local g = graph:new{window={-3,3,0,2},size={10,10}}
    g:Linecap("round")
    g:Saveattr(); g:Viewport(-2.5,-.5,0,2); g:Coordsystem(-2,2,-2,2,true)
    local F = function(x,y) return (x^2+y^2)^2 - 2 * 4 * x * y end
    g:Dimplicit(F,{grid={500,500},draw_options="thick"})
    g:Daxes(
        {0,2.5,2.5},{arrows="-latex",legend={"$x$","$y$"},labelpos={"top","right"},originpos={"none","none"}}
    )
    g:Restoreattr()
    g:Saveattr(); g:Viewport(2.5,0,0,2); g:Coordsystem(-2.5,2.5,-2,2,true)
    local G = function(x,y) return (x^2+y^2)^2 - 4 * (x^2 - y^2) end
    g:Dimplicit(G,{grid={500,500},draw_options="thick"})
    g:Daxes(
        {0,3,3},{arrows="-latex",legend={"$x$","$y$"},labelpos={"top","right"},originpos={"none","none"}}
    )
    g:Restoreattr()
    g:Show()
\end{luadraw}
\end{document} 

image.png

发布
问题