vscode-ultra-math-preview
vscode-ultra-math-preview copied to clipboard
Fix a bug in environment multline
When using environment multline, this plugin cannot render correctly...
Could you please give me the file in which you find the bug? I will try to debug tomorrow.
Could you please give me the file in which you find the bug? I will try to debug tomorrow.
I will give you a minimum file to reproduce this, after a few hours of sleep however
Could you please give me the file in which you find the bug? I will try to debug tomorrow.
feel sorry that it seems difficult to reproduce this. but I found environment multline* won't trigger this plug? I used environment multlined in \[\] and it rendered correctly this time.
% document class
\documentclass[UTF8,10pt,a4paper,oneside]{article}
% packages
\usepackage{ctex} % this is a Chinese article
\usepackage{geometry} % changes margins
\usepackage{graphicx} % insert a picture if you need!
\usepackage{fancyhdr} % provides page footer and header
\usepackage{xcolor} % changes the color of characters
\usepackage{amsmath} % a basic math package
\usepackage{amssymb} % a set of math symbols, check `unimath-symbols' first, which is more recommended
\usepackage{mathtools} % provides a set of useful commands to adjust your math formulas
\usepackage[bold-style=ISO,math-style=ISO,warnings-off={mathtools-colon,mathtools-underbracket,mathtools-overbracket}]{unicode-math} % provides math font
\usepackage{physics} % quantities of useful commands are provided
\usepackage[unimath]{physicx} % add support for unicode-math
\usepackage[shortlabels]{enumitem} % provides some options to change your enumerate and itemize
\usepackage{setspace} % changes the space between lines
\usepackage{multicol} % multi columns
\usepackage{booktabs} % draw essay tables
% commands and definitions
\def\ttop{复变函数第10次作业} % your title here
\def\name{XXX} % your name here
\def\id{00000000000000} % your id here
\def\i{\mathrm{i}} % the unit of imaginary numbers
\def\deq{\overset{\underset{\mathrm{def}}{}}{=}} % define something as...
\def\vc#1{\symbf{#1}} % your style of vectors
\def\mti#1{\symbf{#1}} % your style of matrices
\def\tns#1{\symbfsf{#1}} % your style of tensors
\DeclareMathOperator{\Ln}{Ln} % function Ln in complex analysis
\DeclareMathOperator{\Arctan}{Arctan} % function Arctan in complex analysis
\DeclareMathOperator{\Arg}{Arg} % function Arg in complex analysis
\AtBeginDocument{
\let\real\Re
\DeclareDocumentCommand\Re{g}{\IfNoValueTF{#1}{\operatorname{Re}}{\fbraces{\lbrace}{\rbrace}{\operatorname{Re}}{#1}}}
\let\imaginary\Im
\DeclareDocumentCommand\Im{g}{\IfNoValueTF{#1}{\operatorname{Im}}{\fbraces{\lbrace}{\rbrace}{\operatorname{Im}}{#1}}}
} % redefine Re and Im
% page size
\geometry{a4paper,left=2cm,right=2cm,top=2.5cm,bottom=2.5cm}
\linespread{1.2}
% counters
\newcounter{problems}
% environments
\newenvironment{problem}{\stepcounter{problems}\par\noindent\heiti 题\arabic{problems}.}{\par\vskip 0.1cm}
\newenvironment{proof}{\begin{spacing}{1.5}\par\noindent\it 证明.}{\par\hfill$\square$\end{spacing}\par\vskip 0.1cm}
\newenvironment{note}{\begin{spacing}{1.5}\par\noindent\it 注.}{\end{spacing}\par\vskip 0.1cm}
% page header and footer
\pagestyle{fancy}
\fancyhead{}
\fancyfoot{}
\fancyhead[L]{\slshape \MakeUppercase{\ttop}}
\fancyhead[R]{\slshape \id}
\fancyfoot[C]{\thepage}
%title
\title{\heiti\ttop}
\author{\kaishu 学生: \name\hskip 4cm 学号: \id\hskip 5cm}
\date{} % use blank to ignore date
% font
\setmathfont{Erewhon Math}
\setmathfont{LibertinusMath-Regular.otf}[range="1D4B6-"1D4CF,Scale=MatchLowercase]
\setmathfont{XITS Math}[range={scr,bfscr},Scale=MatchLowercase]
\setmainfont{erewhon}
\setsansfont{Cabin}[Scale=MatchLowercase]
\setmonofont{Inconsolatazi4}[Scale=MatchLowercase]
% formula
\everymath{\displaystyle}
% enumerate styles
\SetEnumitemKey{2c}{
itemsep = 1\itemsep,
parsep = 1\parsep,
before = \raggedcolumns\begin{multicols}{2},
after = \end{multicols}}
\SetEnumitemKey{3c}{
itemsep = 1\itemsep,
parsep = 1\parsep,
before = \raggedcolumns\begin{multicols}{3},
after = \end{multicols}}
\SetEnumitemKey{4c}{
itemsep = 1\itemsep,
parsep = 1\parsep,
before = \raggedcolumns\begin{multicols}{4},
after = \end{multicols}}
% contents
\begin{document}
\maketitle
\thispagestyle{plain}
% write here
\begin{problem}
\begin{enumerate}[(1),2c]
\item $\int_{0}^{+\infty}\frac{\ln x}{(x^{2}+1)^{2}}\dd{x}$;
\item $\int_{0}^{+\infty}\frac{x^{1-a}}{1+x^{2}}\dd{x}\qq{where}0<a<2$;
\end{enumerate}
\begin{enumerate}[(1),2c,resume]
\item $\int_{0}^{+\infty}\frac{\sin ^{2}x}{x^{2}}\dd{x}$;
\item $\int_{0}^{+\infty}\frac{\dd{x}}{1+x^{n}}\qq{where}n\in \symbb{Z},n\geqslant 2$;
\end{enumerate}
\begin{enumerate}[(1),2c,resume]
\item $\int_{0}^{+\infty}\frac{\ln x}{x^{2}-1}\dd{x}$;
\end{enumerate}
\end{problem}
\begin{proof}
\begin{enumerate}[(1)]
\item 考虑多值函数 $f(z)=\frac{(\Ln z)^{2}}{(z^{2}+1)^{2}}$,
以正实轴为割线取解析分支, 如课本 \underline{图 25} 的积分路径,
于是有
\[
\int _{\Gamma _{r}}\frac{(\ln z)^{2}}{(z^{2}+1)^{2}}\dd{z}+
\int_{r}^{\varepsilon} \frac{(\ln x+2\pi \i)^{2}}{(x^{2}+1)^{2}}\dd{x}+
\int_{\Gamma \varepsilon}\frac{(\ln z)^{2}}{(z^{2}+1)^{2}}\dd{z}+
\int_{\varepsilon}^{r} \frac{\ln ^{2}x}{(x^{2}+1)^{2}}\dd{x}=
2\pi \i\bigl(\Res[f,-\i]+\Res[f,\i]\bigr),
\]
计算 $f(z)$ 的洛朗展式, 得到
\[
\Res[f,\i]=\frac{\i}{16}\pi ^{2}-\frac{\pi}{4},\quad
\Res[f,-\i]=-\frac{9}{16}\i \pi ^{2}+\frac{3}{4}\pi,
\]
考虑左边的复变函数积分, 类似课本例题可以证明
\[
\lim_{r \to +\infty}\int_{\Gamma _{r}}f(z)\dd{z}=0,\quad
\lim_{\varepsilon \to 0^{+}}\int _{\Gamma _{\varepsilon}}f(z)=0,
\]
令 $r\to +\infty,\varepsilon \to 0^{+}$, 得到
\[
-4\pi\i\int_{0}^{+\infty} \frac{\ln x}{(x^{2}+1)^{2}}\dd{x}+
4\pi ^{2}\int_{0}^{+\infty}\frac{1}{(x^{2}+1)^{2}}\dd{x}=
\pi ^{3}+\pi ^{2}\i,
\]
比较虚部得到
\[
\int_{0}^{+\infty}\frac{\ln x}{(x^{2}+1)^{2}}\dd{x}=-\frac{\pi}{4}.
\]
\item 仍以正实轴为割线, 取多值函数 $f(z)=\frac{z^{1-a}}{1+z^{2}}$ 的解析分支,
积分路径如课本 \underline{图 25}, 得到
\[
\int_{\Gamma _{r}}\frac{z^{1-a}}{1+z^{2}}\dd{z}+
\int_{r}^{\varepsilon}\frac{x^{1-a}\cdot e^{-2a\pi \i}}{1+x^{2}}\dd{x}+
\int _{\Gamma _{\varepsilon}}\frac{z^{1-a}}{1+z^{2}}\dd{z}+
\int_{\varepsilon}^{r}\frac{x^{1-a}}{1+x^{2}}\dd{x}=
2\pi \i\bigl(\Res[f,-\i]+\Res[f,\i]\bigr),
\]
计算 $f(z)$ 的洛朗展式, 得到
\[
\Res[f,\i]=\frac{1}{2}e^{-\frac{1}{2}a\pi \i},\quad
\Res[f,-\i]=\frac{1}{2}e^{-\frac{3}{2}a\pi \i},
\]
考虑左边的复变函数积分, 类似课本例题可以证明
\[
\lim_{r \to +\infty}\int_{\Gamma _{r}}f(z)\dd{z}=0,\quad
\lim_{\varepsilon \to 0^{+}}\int _{\Gamma _{\varepsilon}}f(z)\dd{z}=0,
\]
令 $r\to +\infty,\varepsilon \to 0^{+}$, 得到
\[
(1-e^{-2a\pi \i})\int_{0}^{+\infty}\frac{x^{1-a}}{1+x^{2}}\dd{x}=
\pi \i(e^{-\frac{1}{2}a\pi \i}+e^{-\frac{3}{2}a\pi \i}),
\]
从而有
\[
\int_{0}^{+\infty}\frac{x^{1-a}}{1+x^{2}}\dd{x}=\frac{\pi/2}{\sin (a\pi/2)}.
\]
\item 由于
\[
\int_{0}^{+\infty}\frac{\sin ^{2}x}{x^{2}}\dd{x}=
\int_{0}^{+\infty}\frac{1-\cos x}{x^{2}}\dd{x},
\]
考虑复值函数 $f(z)=\frac{1-e^{\i z}}{z^{2}}$,
取课本 \underline{图 24} 的积分路径, 则
\[
\int_{\varepsilon}^{r} \frac{1-e^{\i x}}{x^{2}}\dd{x}+
\int _{\Gamma _{r}}\frac{1-e^{\i z}}{z^{2}}\dd{z}+
\int_{-r}^{-\varepsilon} \frac{1-e^{\i x}}{x^{2}}\dd{x}+
\int _{\Gamma _{\varepsilon}} \frac{1-e^{\i z}}{z^{2}}\dd{z}=0,
\]
由于
\[
\lim_{r \to +\infty}\int _{\Gamma _{r}}f(z)\dd{z}=0,\quad
\lim_{\varepsilon \to 0^{+}}\int _{\Gamma _{\varepsilon}}f(z)\dd{z}=-\pi,
\]
令 $r\to +\infty,\varepsilon \to 0^{+}$, 得到
\[
\int_{0}^{+\infty}\frac{1-e^{\i x}}{x^{2}}\dd{x}+
\int_{-\infty}^{0} \frac{1-e^{\i x}}{x^{2}}\dd{x}=
\int_{0}^{+\infty} \frac{2-e^{\i x}-e^{-\i x}}{x^{2}}\dd{x}=
2\int_{0}^{+\infty} \frac{\sin ^{2}x}{x^{2}}=\pi,
\]
即
\[
\int_{0}^{+\infty}\frac{\sin ^{2}x}{x^{2}}=\frac{\pi}{2}.
\]
\item 考虑复值函数 $f(z)=\frac{1}{1+z^{n}}$,
现以射线 $\theta=0,\frac{2\pi}{n}$ 以及角为
$\frac{2\pi}{n}$ 的圆弧 $\Gamma$ 构成的封闭图形为积分路径,
则
\[
\int_{0}^{r}\frac{\dd{x}}{1+x^{n}}+
\int _{\Gamma}\frac{\dd{z}}{1+z^{n}}+
e^{\frac{2}{n}\i \pi}\int_{r}^{0} \frac{\dd{x}}{1+x^{n}}=
2\pi \i\Res[f,e^{\frac{1}{n}\i\pi}],
\]
根据洛朗展式得到
\[
\Res[f,e^{\frac{2}{n}\i \pi}]=
-\frac{1}{n}e^{\frac{1}{n}\i\pi},
\]
考虑复变函数积分, 根据模的变化不难得到
\[
\lim_{r \to +\infty}\int_{\Gamma}f(z)\dd{z}=0,
\]
现在令 $r\to +\infty$, 有
\[
(1-e^{\frac{2}{n}\i\pi})\int_{0}^{+\infty} \frac{\dd{x}}{1+x^{n}}=
-\frac{2}{n}\i\pi e^{\frac{1}{n}\i\pi},
\]
即
\[
\int_{0}^{r} \frac{\dd{x}}{1+x^{n}}=\frac{\pi / n}{\sin (\pi / n)}.
\]
\item 采用类似课本 \underline{图 25} 的积分路径, 但将 $x$ 轴下沿路径在
$z=1$ 处绕一半径 $r=\delta$ 小圆周, 考虑函数 $f(z)=\frac{(\Ln z)^{2}}{z^{2}-1}$,
仍取正实轴为割线. 有
\begin{multline*}
\int _{\Gamma _{r}} \frac{(\ln z)^{2}}{z^{2}-1}\dd{z}+
\int_{r}^{1+\delta} \frac{(\ln x+2\pi \i)^{2}}{x^{2}-1}\dd{x}+
\int _{\Gamma _{\delta}} \frac{(\ln z)^{2}}{z^{2}-1}\dd{z}+\\
\int_{1-\delta}^{\varepsilon} \frac{(\ln x+2\pi \i)^{2}}{x^{2}-1}\dd{x}+
\int _{\Gamma _{\varepsilon}} \frac{(\ln z)^{2}}{z^{2}-1}\dd{z}+
\int_{\varepsilon}^{r} \frac{\ln ^{2}x}{x^{2}-1}\dd{x}=
2\pi \i\Res[f,-1],
\end{multline*}
根据洛朗展式得到
\[
\Res[f,-1]=\frac{1}{2}\pi ^{2},
\]
与前问类似, 有
\[
\lim_{r \to +\infty}\int _{\Gamma _{r}}f(z)\dd{z}=0,\quad
\lim_{\varepsilon \to 0^{+}}\int _{\Gamma _{\varepsilon}}f(z)\dd{z}=0,
\]
而
\[
\lim_{\delta \to 0^{+}}\int_{\Gamma _{\delta}}f(z)\dd{z}=2\pi ^{3}\i,
\]
令 $r\to +\infty,\varepsilon \to 0^{+},\delta \to 0^{+}$, 得到
\[
-4\pi \i \int_{0}^{+\infty} \frac{\ln x}{x^{2}-1}\dd{x}+
4\pi ^{2}\int_{0}^{+\infty} \frac{\dd{x}}{x^{2}-1}=
-\pi ^{3}\i,
\]
比较虚部, 即得到
\[
\int_{0}^{+\infty} \frac{\ln x}{x^{2}-1}\dd{x}=\frac{\pi ^{2}}{4}.
\]
\begin{note}
这里积分 $\int_{0}^{+\infty}\frac{\dd{x}}{x^{2}-1}=\int_{0}^{1}+\int_{1}^{+\infty} \frac{\dd{x}}{x^{2}-1}$
并不收敛, 实际上取到了某个主值.
\end{note}
\end{enumerate}
\end{proof}
here is the code. you should move down to next formula of the multlined one, and then move back to it.
I can reproduce this bug. It is because multline
environment haven't been defined in this extension. It will be fixed in next version.
Try this:
This is a beta version and I will test more before publishing.
I can reproduce this bug. It is because
multline
environment haven't been defined in this extension. It will be fixed in next version.Try this:
This is a beta version and I will test more before publishing.
it works! besides fixing this bug, what's new?
Hmm.....Fix #6 . And maybe nothing new... (See CHANGELOG) So I will not publish this version immediately. 🧐
And I'm testing real-time preview for the whole file. But it is full of bugs🤣 It needs more time to fix and improve.
Hmm.....Fix #6 . And maybe nothing new... (See CHANGELOG) So I will not publish this version immediately. 🧐
And I'm testing real-time preview for the whole file. But it is full of bugs🤣 It needs more time to fix and improve.
I feel like it is supposed to be extremely useful in markdown? But maybe not in latex... I do not use markdown often, but this actually changes VSCode into typora hhh😁
Yep..and now only $
,\[\]
and \(\)
are supported in latex
file in this real-time version. I will try to add more math environments.
Hopefully this might make some difference🤣.
This version may be released this summer.