0.精通lshort-zh-cn
,没有基础和一定的debug能力很难做开发
1.找几个同类的「论文模板」作为参照
2.分析其大致需要哪些模块的功能,使用了哪些宏包
3.精读这些宏包的文档并进一步看懂这些模板的源码
4.根据贵校的论文格式规范做修改,完善模板
notes:不用过多涉及plain-tex,是否需要latex3要看个人选择.
0.精通lshort-zh-cn
,没有基础和一定的debug能力很难做开发
1.找几个同类的「论文模板」作为参照
2.分析其大致需要哪些模块的功能,使用了哪些宏包
3.精读这些宏包的文档并进一步看懂这些模板的源码
4.根据贵校的论文格式规范做修改,完善模板
notes:不用过多涉及plain-tex,是否需要latex3要看个人选择.
It seemly consists two questions:
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
功能做类似的实现。
\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}
同时它要接受一些参数,并将其传递给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}
并没有报错,所以这是"非常独特的",当且仅当同时使用frame
内嵌spacing
才会触发错误。
最后从这个链接来看,用\setstretch
可以规避这一问题,所以有了workaround...
翻到一个神奇的结论:
由于beamer
实在是太坏了。egreg说:
Moral of the story
Don't usesetspace
withbeamer
😀.
感谢@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}
不过我不确定若右侧内容中存在\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}
直观上一种可行的办法也许是把多余的行一分为二...
但这样的坏处也是显然的:
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.
可能你需要检查一下在wsl
中epstopdf
程序是否存在,是否可以直接运行.
一个基于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}
这是普通的行间距。对于中文,会被ctex
通过默认的scheme=chinese
设置为1.3倍...
如果你确实希望缩短全文的中文行距,可以用:scheme=plain
...
同时enumitem
提供了noitemsep
,最好不要手动以不准确的方式微调参数:
\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}
\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}
\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}
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}
哇...根源貌似找到了: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}
此时对于正文段落的间距\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}
沉默...
把评论区中的测试代码搬到我们的目标「希望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}
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
\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}
\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}
可以试试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}
不知道效果对不对...
but why not \visible<\thenaturevisible->{#2}
instead of \visible<thenaturevisible->{#2}
?
你可以试试「只有法语文档」的luadraw
宏包:
% https://ask.latexstudio.net/ask/question/7513.html
\documentclass{standalone}
\usepackage{luadraw}
\begin{document}
\begin{luadraw}{name=implicit_function}
local g = graph:new{window={-3,3,-3,3},size={10,10}}
g:Linecap("round")
local F = function(x,y) return x^2+y^2+x*y-1 end
g:Dimplicit(F,{draw_options="thick"})
g:Dgradbox(
{Z(-2,-2),Z(2,2),1,1},{grid=true,title="\\textbf{Implicit Function Plot}"}
)
g:Show()
\end{luadraw}
\end{document}
\documentclass{standalone}
\usepackage{luadraw}
\begin{document}
\begin{luadraw}{name=implicit_function_tangentline}
local g = graph:new{window={-3,3,-3,3},size={10,10}}
g:Linecap("round")
% https://github.com/pfradin/luadraw/blob/a2759c0aeaf73e023362fac960ffdf704470925a/files/luadraw_lines.lua#L406-L421
local DtangentI = function(f,x0,y0,len,draw_options) -- f:(x,y()) -> f(x,y)
-- We assume that f(x0,y0)=0!
local h = 1e-6
local A = Z(x0,y0) -- 定义复数点(x0,y0)
local a,b = (f(x0+h,y0)-f(x0-h,y0))/(2*h), (f(x0,y0+h)-f(x0,y0-h))/(2*h)
-- 定义 a,b 为f(x0)处的两个偏导数
local v = Z(-b,a)
if len == nil then -- 如果传入的参数为空,则绘制整条直线
g:Dline({A,v},draw_options)
else
local u = len*v/cpx.abs(v)/2 -- 否则往两侧绘制长度为 len/2 的线段
g:Dseg({A-u,A+u},draw_options) -- 绘制线段
end
end
local F = function(x,y) return x^2+y^2+x*y-1 end
g:Dimplicit(F,{draw_options="thick"})
g:Dgradbox(
{Z(-2,-2),Z(2,2),1,1},{grid=true,title="\\textbf{Implicit Function Plot}"}
)
local x0 = 1/2
local L = solve(function(t) return F(x0,t) end,-2,2) -- 求解两个根获得直线的y_i坐标
for _, y in ipairs(L) do -- 循环绘制多条切线
DtangentI(F,x0,y,2,"thick,red") -- This work!
end
g:Show()
\end{luadraw}
\end{document}
问 普通民办二本大二学生想做学校论文模板的问题.