VsCode LaTeX 用户代码片段——效率++

VsCode LaTeX 用户代码片段

增加代码片段可以在日常写文档的过程中,提高效率。因为很多写作的内容都是重复的,没必要每次都要去写一次。代码片段很好的解决了这个问题。

snippets

分享我的Vscode LaTeX的代码片段:

复制直接使用即可。

在VSCode中,按ctrl+shift+P弹出搜索,输入snippets,找到或者输入latex,进入latex.json,粘贴进去就可以了。

{
	"compile setting":{
		"prefix": "compile",
		"body": ["%!TEX program = ${1:xelatex} -> bibtex -> xelatex -> ${1:xelatex}"],
		"description": "set default the compile order"
	},
	"insert figure":{
		"prefix": "figure",
		"body":["\\begin{figure}[htbp]\n\t\\centering\n\t\\includegraphics[width=${1}\\textwidth]{picture/${2}}\n\t\\caption{${3}}\n\t\\label{${4}}\n\\end{figure}"],
		"description": "insert figure snippet"
	},
	"insert table":{
		"prefix": "table",
		"body":["\\begin{table}[${1:htbp}]\n\t\\centering\n\t\\caption{${2:caption}}\n\t\t\\begin{tabular}{${3:c|c}}\n\t\t\\hline\n\t\t${4:column1 & column2}\n\t\t\\end{tabular}\n\t\\label{${5:label}}\n\\end{table}"],
		"description": "insert table snippet"
	},
	"insert enumerate":{
		"prefix": "enumerate",
		"body":["\\begin{enumerate}\n\t\\item ${1:enumerate1}\n\t\\item ${2:enumerate2}\n\\end{enumerate}"],
		"description": "insert enumerate snippet"
	},
	"insert item":{
		"prefix": "itemize",
		"body":["\\begin{itemize}\n\t\\item ${1:itemsize1}\n\t\\item ${2:itemsize2}\n\\end{itemize}"],
		"description": "insert item snippet"
	},
	"insert frame":{
		"prefix": "frame",
		"body":["\\begin{frame}{${1}}\n\t${2}\n\\end{frame}"],
		"description": "insert frame snippet"
	},
	"insert paragraph":{
		"prefix": "paragraph",
		"body":["\\paragraph{${1}}~{}\\par"],
		"description": "insert paragraph snippet"
	},
	"insert columns":{
		"prefix": "columns",
		"body":["\\begin{columns}\n\t\\column{0.5\\textwidth}\n${1}\n\t\\column{0.5\\textwidth}\n\\end{columns}"],
		"description": "insert columns snippet"
	},
	"insert figures":{
		"prefix": "figures",
		"body":["\\begin{figure*}[htbp]\n\t\\begin{minipage}{0.5\\textwidth}\n\t\t\\includegraphics[width=${1}\\textwidth]{picture/${2}}\n\t\t\\caption{${3}}\n\t\t\\label{${4}}\n\t\\end{minipage}\n\t\\hfill\n\t\\begin{minipage}{0.5\\textwidth}\n\t\t\\includegraphics[width=${1}\\textwidth]{picture/${2}}\n\t\t\\caption{${3}}\n\t\t\\label{${4}}\n\t\\end{minipage}\n\\end{figure*}"],
		"description": "insert figures snippet"
	},
	"insert algorithmic":{
		"prefix": "algorithmic",
		"body":["%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n%\\STATE\\IF  \\ENDIF\\FOR \\ENDFOR\\FOR \\TO  \\ENDFOR\\FORALL \n%\\ENDFOR\\WHILE \\ENDWHILE\\REPEAT  \\UNTIL\\LOOP\n%\\ENDLOOP\\REQUIRE \\ENSURE \\RETURN \\PRINT \\COMMENT,\\AND, \\OR, \\XOR, \\NOT, \\TO, \\TRUE, \\FALSE \n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\\begin{algorithm}[htbp]\n\t\\caption{${1}}\n\t\\label{al:${2}}\n\t\\begin{algorithmic}\n\t\t\\REQUIRE{${3}}\n\t\t\\ENSURE{${3}}\n\t\\end{algorithmic}\n\\end{algorithm}"],
		"description": "insert algorithmic snippet"
	},
	"insert algorithm":{
		"prefix": "algorithm",
		"body":["\\begin{algorithm}[htbp]\n\t\\caption{${1}}\n\t\\label{al:${2}}\n\t\t\\KwIn{${3}}\n\t\t\\KwOut{${3}}\n\\end{algorithm}"],
		"description": "insert algorithm snippet"
	},
	"insert thebibliography":{
		"prefix": "thebibliography",
		"body":["\\begin{thebibliography}{99}\n\t\\bibitem{ref1} \n\t\\bibitem{ref2} \n\\end{thebibliography}"],
		"description": "insert thebibliography snippet"
	},
}


以上代码片段主要有:

figure

\begin{figure}[htbp]
	\centering
	\includegraphics[width=\textwidth]{picture/}
	\caption{}
	\label{}
\end{figure}

table

\begin{table}[htbp]
	\centering
	\caption{caption}
		\begin{tabular}{c|c}
		\hline
		column1 & column2
		\end{tabular}
	\label{label}
\end{table}

columns

(这个主要是用来写两栏内容的,比如Beamer多个图片并列放置)

\begin{columns}
	\column{0.5\textwidth}

	\column{0.5\textwidth}
\end{columns}

Algorithm

\begin{algorithm}[htbp]
	\caption{}
	\label{al:}
		\KwIn{}
		\KwOut{}
\end{algorithm}

Algorithmic

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\STATE\IF  \ENDIF\FOR \ENDFOR\FOR \TO  \ENDFOR\FORALL 
%\ENDFOR\WHILE \ENDWHILE\REPEAT  \UNTIL\LOOP
%\ENDLOOP\REQUIRE \ENSURE \RETURN \PRINT \COMMENT,\AND, \OR, \XOR, \NOT, \TO, \TRUE, \FALSE 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{algorithm}[htbp]
	\caption{}
	\label{al:}
	\begin{algorithmic}
		\REQUIRE{}
		\ENSURE{}
	\end{algorithmic}
\end{algorithm}

thebibliography

参考文献

\begin{thebibliography}{99}
	\bibitem{ref1} 
	\bibitem{ref2} 
\end{thebibliography}

frame

使用beamer时,快速插入一个frame

\begin{frame}{}
	
\end{frame}

enumerate

\begin{enumerate}
	\item enumerate1
	\item enumerate2
\end{enumerate}

itemize

\begin{itemize}
	\item itemsize1
	\item itemsize2
\end{itemize}

paragraph

这个用来自动换行paragraph

\paragraph{}~{}\par
  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AlphaGuaGua

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值