【LaTeX】Lyx/LaTeX笔记02

本文介绍如何在LyX中使用命令行窗口进行高效操作,包括定义数学宏、快速编译文档以及设置快捷键等技巧。通过本文,用户能够掌握LyX命令行的使用方法,提高编辑效率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Command Buffer

  view->toolbars->command buffer 会在窗口最下面显示出来命令行窗口,M-x可以激活此窗口,Tab键会出现提示。

  可以在此窗口中输入命令(实际上是Lyx函数),例如:math-matrix 2 2则会生成一个2*2的矩阵,比点击鼠标然后再输入2*2要快些。

  此处输入的命令均为lyx特有的(非LaTeX命令)例如:buffer-view pdf4则会调用xelatex编译当前文档,可以在菜单tools->preferences->Editing->Shortcuts中看到一些命令并可以在这里设置快捷键,例如新添加 buffer-view pdf4并定义快捷键为Ctrl-R(首先删掉buffer-view的快捷键),则以后便可以用Ctrl-R来调用xelatex来编译文档。

  可以在此窗口中定义数学宏:math-macro macroname args 其中macroname为宏名称,args为可选参数,为数字,表参数的个数。之后lyx便会打开math macro环境,便可以定义math macro了。

Math Macro

  参考视频:http://www.youtube.com/watch?v=68Gys4rp3u4

  定义MathMacro的方法有多种:

  • 例如在lyx文档中输入:\newcommand{\foo}[2]{\sqrt{\frac{#1}{#2}}} 选中刚输入的内容后Ctrl-M便可看到定义的宏形式。
  • M-x激活command buffer如上所述,输入math-macro foo 2即可进入MathMacro的编辑环境,可见:=后面有两个[],第一个为在生成pdf中显示的,第二个是在lyx文档中显示的(为了在视觉上简化公式,便于修改)。在第一个中输入 \#1^\#2,效果同上(此时要使用参数必须加转义\)
  • Insert->Math->Math Macro,可以在下面的math bar中添加参数、删除参数……
使用:

  进入公式编辑环境后输入\foo回车即可将宏展开,输入公式即可。

Lyx enumerate环境列表以指定编号开始

Alt-P E先所有的列表都输完后,光标放在列表上,view->view source查看其源码

Ctrl-L加入source窗口的TeX源码并修改:

\begin{enumerate}
\setcounter{enumi}{-1} %%%%此处为修改编号起始命令,若要以n编号开始,则此处用n-1,此处-1表以0开始
\item 给定初始点$x_{0}$和初始参数,并令$k\triangleq0$
\item xxxxxxxxxxxxxxxxx \end{enumerate}

 

修改快捷键

工具栏上有个按键toggle-outline,现在我要为他赋快捷键,首先要知道它的函数名,Windows下在C:/Program Files/LyX20/Resources下,打开stdtoolbars.inc搜索outline可以看到它的函数是toogle-outline

Tools->Preferences->Editing->Shortcuts中New对话框中Function栏写toogle-outline,快捷键一栏中按下快捷键Control F4,保存后同时按下Ctrl-F4就可以切换outline视图了。

同理为其它功能赋快捷键思路也是一样的。

设置公式编号与章节相关

Document->Settings->Math Options将Use AMS math package automatically改选成Use AMS math package,将Use esint math package automatically改选成Use esint math package。

在导言区加入\numberwithin{equation}{section}即可。

设置隐藏菜单、工具栏、状态栏、滚动条快捷键

对应的函数分别为ui-toggle statusbar; ui-toggle scrollbar; ui-toggle menubar; ui-toggle frame; toolbar-toggle standard; toolbar-toggle vcs; toolbar-toggle extra; toolbar-toggle minibuffer

修改快捷键参考上上节

This is pdfTeX, Version 3.141592653-2.6-1.40.26 (TeX Live 2024) (preloaded format=pdflatex) restricted \write18 enabled. entering extended mode (d:/桌面/毕设/1_[海南大学][HNU]2024届本科生毕业论文/Thesis/hnumain.tex LaTeX2e <2023-11-01> patch level 1 L3 programming layer <2024-02-20> (e:/E/latex/Latex/texlive/2024/texmf-dist/tex/latex/ctex/ctexbook.cls (e:/E/latex/Latex/texlive/2024/texmf-dist/tex/latex/ctex/config/ctexbackend.cfg) (e:/E/latex/Latex/texlive/2024/texmf-dist/tex/latex/l3kernel/expl3.sty (e:/E/latex/Latex/texlive/2024/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def)) Document Class: ctexbook 2022/07/14 v2.5.10 Chinese adapter for class book (CTEX) (e:/E/latex/Latex/texlive/2024/texmf-dist/tex/latex/ctex/ctexhook.sty) (e:/E/latex/Latex/texlive/2024/texmf-dist/tex/latex/ctex/ctexpatch.sty) (e:/E/latex/Latex/texlive/2024/texmf-dist/tex/latex/base/fix-cm.sty (e:/E/latex/Latex/texlive/2024/texmf-dist/tex/latex/base/ts1enc.def)) (e:/E/latex/Latex/texlive/2024/texmf-dist/tex/latex/ctex/config/ctexopts.cfg) Class ctexbook Warning: UTF8 will be used as the default encoding. (e:/E/latex/Latex/texlive/2024/texmf-dist/tex/latex/base/book.cls Document Class: book 2023/05/17 v1.4n Standard LaTeX document class (e:/E/latex/Latex/texlive/2024/texmf-dist/tex/latex/base/bk12.clo)) (e:/E/latex/Latex/texlive/2024/texmf-dist/tex/latex/ctex/engine/ctex-engine-pdftex.def (e:/E/latex/Latex/texlive/2024/texmf-dist/tex/latex/cjk/texinput/CJKutf8.sty (e:/E/latex/Latex/texlive/2024/texmf-dist/tex/generic/iftex/ifpdf.sty (e:/E/latex/Latex/texlive/2024/texmf-dist/tex/generic/iftex/iftex.sty)) (e:/E/latex/Latex/texlive/2024/texmf-dist/tex/latex/base/inputenc.sty) (e:/E/latex/Latex/texlive/2024/texmf-dist/tex/latex/cjk/texinput/CJK.sty (e:/E/latex/Latex/texlive/2024/texmf-dist/tex/latex/cjk/texinput/mule/MULEenc.sty) (e:/E/latex/Latex/texlive/2024/texmf-dist/tex/latex/cjk/texinput/CJK.enc)) (e:/E/latex/Latex/texlive/2024/texmf-dist/tex/latex/base/fontenc.sty)) (e:/E/latex/Latex/texlive/2024/te
最新发布
03-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值