BNU-FZH

fengzhenhua@outlook.com

PDF Mix Tool是Linux下的最佳 PDF 编辑软件之一,也是PDF Arranger的替代品。它是一个用于操作 pdf 文件的简洁的 GUI 工具,可以修改文件(旋转、拆分、从文件中提取),但是不能编辑PDF文件的内容。虽然这个应用程序只提供了一个简洁的工具集,没有附带很多工具,但是,也足以应付日常的使用了。

安装

1
sudo pacman -S pdfmixtool

软件功能

  1. 在新发布的版本中有一个左侧边栏
    在侧边栏中包括你可能需要执行的所有操作的图标。虽然这不是一个重大变化,但是,这有助于增强用户的使用体验。 PdfMixTool侧边栏

  2. PDF元数据编辑
    现在可以修改文档的标题、作者、主题、关键字、创建者、制作者以及创建和修改日期。因此,你可以轻松编辑文档的元数据。 PdfMixTool元数据编辑

  3. 支持Qt6.0
    PDF Mix Tool 是用 C++ 编写的,它依赖于qpdf和Qt库来实现相关功能。

  4. 其他改进

    • PDF Mix Tool 现在在页面组合中添加了从右到左的支持。
    • 在所有操作中都尽可能保留链接、注释和轮廓。
    • 修复了一些BUG。
  5. GitLab源码
    https://gitlab.com/scarpetta/pdfmixtool

  6. 参考文章:PDF Mix Tool | 轻量级PDF编辑软件

在使用Git的过程中,有的文件比如日志,临时文件,编译的中间文件等不要提交到代码仓库,这时就要设置相应的忽略规则,来忽略这些文件的提交。简单来说一个场景:在你使用git add .的时候,遇到了把你不想提交的文件也添加到了缓存中去的情况,比如项目的本地配置信息,如果你上传到Git中去其他人pull下来的时候就会和他本地的配置有冲突,所以这样的个性化配置文件我们一般不把它推送到git服务器中,但是又为了偷懒每次添加缓存的时候都想用git add .而不是手动一个一个文件添加,该怎么办呢?很简单,git为我们提供了一个.gitignore文件,只要在这个文件中声明哪些文件你不希望添加到git中去,这样当你使用git add .的时候这些文件就会被自动忽略掉。

Git忽略文件的原则

  • 忽略操作系统自动生成的文件,比如缩略图等;
  • 忽略编译生成的中间文件、可执行文件等,也就是如果一个文件是通过另一个文件自动生成的,那自动生成的文件就没必要放进版本库,比如产生的.log日志文件;
  • 忽略你自己的带有敏感信息的配置文件,比如存放口令的配置文件。

使用方法

在工作目录中新建一个文件.gitignore, 然后把要忽略的文件名填进去,Git就会自动忽略这些文件。不需要从头写.gitignore文件,GitHub已经为我们准备了各种配置文件,只需要组合一下就可以使用了。 https://github.com/github/gitignore

我的Latex仓库配置

.gitignore
1
2
3
4
5
*.aux
*.log
*.pdf
*.synctex.gz
*.out

参考文章

[Git].gitignore文件的配置使用

在决定全面使用vim-latex来编写latex文件后,发现Alt键一直没有启用。于是在nvim下查询帮助:help latex-suite.txt , 然后找到Alt相关,即

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Latex-Suite utilizes a set of macros originally created by Carl Mueller in
auctex.vim to make inserting all the \left ... \right stuff very easy and to
also make some use of the heavily under-utilized <Alt> key.

NOTE: By default, the mappings involving the <Alt> key are turned off for
compatibility with inserting non-ASCII characters. It can be enabled by
setting
let g:Tex_AdvancedMath = 1
in your $VIM/ftplugin/tex.vim.


NOTE: By default, typing Alt-<key> in Vim takes focus to the menu bar if a menu
with the hotkey <key> exists. If in your case, there are conflicts due to
this behavior, you will need to set
set winaltkeys=no
in your $VIM/ftplugin/tex.vim in order to use these maps.

由于我是在neovim下使用的vim-latex, 于是找到路径为:~/.local/share/nvim/lazy/vim-latex/ftplugin/ 但是发现没有文件tex.vim, 于是, 即

~/.local/share/nvim/lazy/vim-latex/ftplugin/tex.vim
1
2
let g:Tex_AdvancedMath = 1
set winaltkeys=no

经过上述设置后Alt键终于被启用了,我目前使用的主要是它智能插入item的功能。

git是当前最常见的版本控制工具,但出现以下情况时,往往需要清空commits历史记录:

  • commits记录占用空间过大甚至远远超过版本控制文件本身大小,进行云端代码管理时会受制于空间限制,无法继续更新
  • 历史记录中存在敏感信息,需要清理

清理commits历史记录的核心思想是,直接删除本地的.git目录,重新建立git仓库并与远程仓库建立链接,采用强制提交的方式覆盖远程仓库的commits记录。

下面是一段示例,参数说明:

  • $REPO_DIR 表示需要处理的Git仓库本地目录
  • git@github.com:xxxx/$REPO_DIR.git 表示远程仓库地址

进入本地仓库,删除.git目录

1
2
cd $REPO_DIR
rm -rf .git

重新初始化

1
2
git init
git branch -m main

由于Gitlab仓库的默认分支名为main,而仓库初始化默认为master, 所以需要重命名为main.

添加commit

1
2
git add .
git commit -m "restart git commit"

添加远程仓库链接

设置远程仓库代号为origin, 则

1
git remote add orign git@github.com:xxxx/$REPO_DIR.git

注意,此时可用git remote -v检查远程仓库的设置。

强制提交到master分支,覆盖远程仓库的commits历史提交记录

1
2
3
git push -f origin master
or
git push --force origin master

追踪上游分支

1
git push --set-upstream origin main

如果不设置上游分支,再次提交时的commits不能确定跟踪变化,所以不能正常提交博客文章,于是这是一个必须的操作。

参考文章

清空Github仓库的commits历史记录

作为一个理科生,终生都离不开数学公式。而LaTeX绝对是处理数学公式的王者,在编辑LaTeX中的众多工具中,使用vim或neovim配合编辑LaTeX的插件又是王者中的王者。在众多的插件中,vim-latexvimtex是网络上提到最多的,也是使用者最多的插件,但是这两者该如何选择呢?经过本人的实践,最终选择了vim-latex.

选择依据分析

众多网络文章都提到了插件vimtex, 按其官方介绍:VimTeX is a modern Vim and Neovim filetype and syntax plugin for LaTeX files. , 或许就是这个modern让许多人选择了它。诚然vimtex是一个优秀的插件,我们来看一下它提供的功能(引用其README.md):

  • Document compilation with latexmk, latexrun, tectonic, or arara
  • LaTeX log parsing for quickfix entries using
  • Compilation of selected part of document
  • Support for several PDF viewers with forward search
  • Completion of
    • citations
    • labels
    • commands
    • file names for figures, input/include, includepdf, includestandalone
    • glossary entries
    • package and documentclass names based on available .sty and .cls files
  • Document navigation through
    • table of contents
    • table of labels
    • proper settings for 'include', 'includexpr', 'suffixesadd' and 'define', which among other things
      • allow :h include-search and :h definition-search
      • give enhanced gf command
  • Easy access to (online) documentation of packages
  • Word count (through texcount)
  • Motions (link to GIF demonstrations)
    • Move between section boundaries with [[, [], ][, and ]]
    • Move between environment boundaries with [m, [M, ]m, and ]M
    • Move between math environment boundaries with [n, [N, ]n, and ]N
    • Move between frame environment boundaries with [r, [R, ]r, and ]R
    • Move between comment boundaries with [* and ]*
    • Move between matching delimiters with %
  • Text objects (link to GIF demonstrations)
    • ic ac Commands
    • id ad Delimiters
    • ie ae LaTeX environments
    • i$ a$ Math environments
    • iP aP Sections
    • im am Items
  • Other mappings (link to GIF demonstrations)
    • Delete the surrounding command, environment or delimiter with dsc/dse/ds$/dsd
    • Change the surrounding command, environment or delimiter with csc/cse/cs$/csd
    • Toggle starred command or environment with tsc/tse
    • Toggle inline and displaymath with ts$
    • Toggle between e.g. () and \left(\right) with tsd
    • Toggle (inline) fractions with tsf
    • Close the current environment/delimiter in insert mode with ]]
    • Add \left ... \right) modifiers to surrounding delimiters with <F8>
    • Insert new command with <F7>
    • Convenient insert mode mappings for faster typing of e.g. maths
    • Context menu on citations (e.g. \cite{...}) mapped to <cr>
  • Improved folding (:h 'foldexpr')
  • Improved indentation (:h 'indentexpr')
  • Syntax highlighting
    • A consistent core syntax specification
    • General syntax highlighting for several popular LaTeX packages
    • Nested syntax highlighting for several popular LaTeX packages
    • Highlight matching delimiters
  • Support for multi-file project packages

而插件vim-latex(又称latex-suite), 按vimtexREADME.md

The main difference between VimTeX and LaTeX-Suite (aka vim-latex) is probably that VimTeX does not try to implement a full fledged IDE for LaTeX inside Vim. E.g.:

  • VimTeX does not provide a full snippet feature, because this is better handled by UltiSnips or neosnippet or similar snippet engines.
  • VimTeX builds upon Vim principles: It provides text objects for environments, inline math, it provides motions for sections and paragraphs
  • VimTeX uses latexmk, latexrun, tectonic or arara for compilation with a callback feature to get instant feedback on compilation errors
  • VimTeX is very modular: if you don't like a feature, you can turn it off.

这两个插件有相同的部分,比如说输入希腊字母,vim-latex在任何模式下都可以输出对应的希腊字母命令,而vimtex在数学模式中才输出希腊字母,相较而言vimtex更加保险一些,但是对于一个熟悉LaTeX的人来讲,这个事情都是知道的,影响不大,只能说vimtex更加细致一点。而vim-latex提供了完整的LaTeX的输入语法,同时提供了<++>标记方法,可以使用Ctrl+j快速的移动光标,这点是vimtex所无法比拟的。按vimtex的说法,vimtex把补全的任务交给了其他插件,但是就专业性和速度上讲,vim-latex绝对领先。

vimtex提供的较好的特性是光标在各环境中移动,这点是vim-latex不具备的功能。但是vimneovim的特性,使用搜索功能或数字键加hjkl方式移动光标,好像vimtex也没有占据足够的优势。

vimtex方便的更改环境功能,例如cse可以方便的更换为新的环境,但是vim-latex也可以使用<S-F5>快捷键快速更换环境,再则考虑到编写环境前作者肯定是规划好的环境,所以更改环境是一个低概率事件。此处注意,Neovim中同时按下组键<S+F5>(也就是Shift+F5)返回的是F17,并不能获得vim-latex所需的组合键<S-F5>!! 具体请参考keycode in terminal for vim&neovim, 于是做出修改:

~/.config/nvim/init.vim
1
2
3
4
map <F17> <S-F5>
imap <F17> <S-F5>
map <F19> <S-F7>
imap <F19> <S-F7>

修改完毕,在neovim中可以正常使用环境或命令的替换。很多人选择vimtex的一个重要原因是其可以配置增量编译,实现时时查看结果,但是LaTeX的精神本身就是!对于一个熟悉LaTeX的人来讲随时关注结果并不是必须的,除非公式比较复杂,而这只需要编译一下看看结果即可。时时编译的代价就是电脑消耗更多的资源,对于我的笔记本来说,风扇一直转发出的噪音会干扰我的写作思维。对于一个初入LaTeX的人,这或许是一个较好的选择,但是对于一个足够熟悉LaTeX的人来讲,不是必须的,也是符合Linux思维。

综上所述,vim-latexvimtex都是优秀的LaTeX插件,但是前者提供了完备的功能,后者的优势功能是一些低频率使用的功能,综合平衡的话还是选择vim-latex更好一些。由于二者并不冲突,所以可以同时配置二个插件,获取各自的功能这是一个比较折中的方案,但是不太符合Linux纯净化的哲学思想,所以我还是选择了前者,在没有足够的理由前应该不会同时安装二者。

作为可用的配置,下面将二者的配置文件列出,方便大家参考:

~/.config/nvim/lua/plg/vim-latex.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#! /usr/bin/env lua
--
-- vim-latex.lua
-- Copyright (C) 2023 feng <feng@arch>
--
-- Distributed under terms of the MIT license.
--
-- vim-latex默认的局势键
-- F1 帮助菜单
-- F5 插入环境选择对话框,若在导言区将弹出插入宏包对话框
-- F7 插入引用选择对话框
--绑定快捷键
-- -- 测试功能
-- inoremap <buffer><silent> <C-S-F5> <C-O>:call <SID>ChangeEnvironment(input('Environment? '))<CR>
-- noremap <buffer><silent> <C-S-F5> :call <SID>ChangeEnvironment(input('Environment? '))<CR>
vim.api.nvim_create_autocmd("FileType",{
pattern = "tex",
callback = function()
-- 配置F4打开模板
vim.api.nvim_set_keymap("n", "<F4>", ":TTemplate<CR>", {noremap = true, silent = true})
-- 配置pdflatex编译,原vim-latex中使用\ll 默认 xelatex 编译
vim.api.nvim_set_keymap("n", "<F6>", [[<cmd>!pdflatex % <CR>]], {noremap = true, silent = true})
-- 配置F8编译 aux辅助文件,直接根据数据库生成文献引用, 注意使用%:t:r 截取文件名
vim.api.nvim_set_keymap("n", "<F8>", [[<cmd>!bibtex %:t:r.aux <CR>]], {noremap = true, silent = true})
-- 配置F10编译多合一文件时,以当前目录名为主文件,以节省时间
vim.api.nvim_set_keymap("n", "<F10>", [[<cmd>!xelatex $(echo $PWD|awk -F"/" '{print $NF}').tex <CR>]], {noremap = true, silent = true})
end
})
-- 开启treesitter提供的语法高亮
vim.api.nvim_create_autocmd( 'FileType', { pattern = 'tex',
callback = function(args)
vim.treesitter.start(args.buf, 'latex')
vim.bo[args.buf].syntax = 'on' -- only if additional legacy syntax is needed
end
})
-- set for vim-latex/latex-suite
vim.g['Tex_Menus'] = 0
vim.g['Tex_Flavor'] = 'latex'
vim.g['Tex_IgnoreLevel'] = 8
vim.g['Tex_GotoError'] = 0
vim.g['Tex_DefaultTargetFormat'] = 'pdf'
-- 配置默认编译引擎为 xelatex
vim.g['Tex_CompileRule_pdf'] = 'xelatex -synctex=1 -interaction=nonstopmode -file-line-error-style $*'
-- 获取桌面环境,并根据桌面环境选择默认的PDF阅读器
if os.getenv("DESKTOP_SESSION") == "plasma" then
vim.g['Tex_ViewRule_pdf'] = 'okular'
else
vim.g['Tex_ViewRule_pdf'] = 'evince'
end
-- 统一设置为轻量级的mupdf阅读器
-- vim.g['Tex_ViewRule_pdf'] = 'mupdf'
--控制统计过程中的警告信息
vim.g['Tex_IgnoredWarnings'] = {}
--
vim.g['Tex_CustomTemplateDirectory'] = "~/.latex-templates/"
~/.config/nvim/lua/plg/vimtex.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#! /usr/bin/env lua
--
-- vimtex.lua
-- Copyright (C) 2023 feng <feng@archlinux>
--
vim.g['tex_flavor'] = 'latex'
vim.g['vimtex_view_method'] = 'zathura'
vim.g['vimtex_view_general_viewer'] = 'zathura'
vim.g['vimtex_view_general_options'] = [[--unique file:@pdf\#src:@line@tex]]
vim.g['vimtex_compiler_latexmk_engines'] = {
_ = '-xelatex'
}
vim.g['vimtex_compiler_progname'] = 'nvr'
-- vim.g['vimtex_view_general_options_latexmk'] = '--unique'
-- vim.g['vimtex_view_general_options_latexmk'] = '--reuse-instance'
--
-- A few examples of disabling default VimTeX features.
vim.g['tex_comment_nospell'] = 1
vim.g['vimtex_quickfix_mode'] = 1
vim.g['vimtex_indent_enabled'] = 1 -- turn off VimTeX indentation
vim.g['vimtex_imaps_enabled'] = 1 -- disable insert mode mappings (e.g. if you use UltiSnips)
vim.g['vimtex_complete_enabled'] = 1 -- turn off completion
vim.g['vimtex_syntax_enabled'] = 1 -- disable syntax conceal
vim.g['vimtex_syntax_conceal_disable'] = 1 --avoid the startup warning
-- 使一些符号以一种更加直观的方式显示出来
vim.g['tex_conceal'] = 'abdmg'
vim.g['conceallevel'] = 1
-- 更改maplocalleader避免与vim-latex的冲突
vim.g['maplocalleader'] = ","

参考文章

  1. VimAwesome
  2. vim-latex.sourceforge
  3. 用Vim高效地编辑LaTeX文档

这是一款可以实现数学符号对齐的插件,测试后发现很实用,于是直接粘上其README.md, 如下

This is a mirror of http://www.vim.org/scripts/script.php?script_id=294

Align and AlignMaps lets you align statements on their equal signs, make comment boxes, align comments, align declarations, etc.

Note: this plugin is not a left&right margin justification tool! See vimscript#177 or vimscript#2324 for that. Note: if you have vim 7.1 or later, your vimball should unpack just fine without having to update it.

There are two basic commands provided by this package:

    AlignCtrl options sep1 sep2 sep3 ... 
    [range]Align sep1 sep2 sep3 ... 

The "sep#" are regular expressions which describe separators that delineate fields; Align will line up the separators. The range may be any Vim range, including visual-blocks. Align works on lines of the form: (ws==whitespace, sep==separator, field==text)

ws-field-ws-sep-ws-field-ws-sep-ws-field-... 
ws-field-ws-sep-ws-field-ws-sep-ws-field-... 

Note that white-space (ws) surrounding separators is ignored.

The Align package includes:

  • Align : the basic alignment command
  • AlignCtrl : provides options for the next call to :Align
  • AlignMaps : many three or four key maps which support aligning C/C++ style declarations, ()?..:.., expressions, C/C++ comments, numbers, C preprocessor definitions, tables based on tabs or spaces, and more.

In addition, AutoAlign (vimscript#884) uses the Align function to align =s as you type.

Align handles alignment on multiple separators, not just the first one, and the separators may be the same across the line or different. With AlignCtrl one may specify that separators are cyclic (re-used sequentially) or equivalent (all separators are simultaneously active).

There are several options to help with deciding what to do with initial white space. By default Align re-uses the first line's initial white space, but one may use AlignCtrl to retain or remove each line's initial white space.

The <Align.vim> and <AlignMaps.vim> files are plugins and require vim 6.1 or higher.

EXAMPLES:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
:5,10Align = 
Align on '=' signs

:'<,'>Align = + - \* /
Align on any of the five separator characters shown.
Note that visual block mode was used to fire off Align.

:AlignCtrl =lp1P1I
which means:
= all separators are equivalent
l fields will be left-justified
p1 pad one space before each separator
P1 pad one space after each separator
I preserve and apply the first line's leading white space to all
Align'd lines

:help align
Gives help for Align

ALIGNMENT CONTROL

Alignment control allows for left or right justification or centering of fields, cyclic (sequentially active) or equivalent (simultaneously active) regular expressions to specify field separators, initial white space control, optional visual-block use (ie. apply Alignment only within a block), user-specified white-space padding about separators, and multiple separators.

MANY ALIGNMENT MAPS

AlignMaps.vim provides a number of maps which make using this package easy. They typically either apply to the range 'a,. (from mark a to current line) or use the visual-selection (V, v, or ctrl-v selected):

1
2
3
4
5
\t=  : align assignments (don't count logic, like == or !=) 
\t, : align on commas
\t| : align on vertical bars (|)
\tsp : align on whitespace
\tt : align LaTeX tabular tables

AlignMaps also provides some internally complex maps for aligning C declarations, Ansi C function arguments, html tables, LaTeX tabulars, and trailing comments:

1
2
3
4
\acom : align comments 
\adec : align C declarations (one variable per line)
\afnc : align ansi-style C function input arguments
\Htd : align html tables

To see some examples of this, check out

[http://mysite.verizon.net/astronaut/vim/align.html#Examples](http://mysite.verizon.net/astronaut/vim/align.html#Examples) 

(the proportional fonts used by most browsers in showing you this page preclude showing the examples here). The help for Align and AlignCtrl also contains many examples.

ALIGNMENT ON VISUAL BLOCKS AND g,v-LIKE CONTROL

Sometimes one wants to align only a subset of text in a range, based on patterns or column extents. Align supports both types of restrictions!

Visual-block selection may be used to restrict Align to operate only 
within that visual block. 
 
AlignCtrl supports "g" and "v" patterns that restrict Align to 

operate on lines which match (or don't match, respectively) those 
patterns. 

NEW STUFF:

There's a number of new AlignCtrl options:

- allows one to skip a separator (treat it as part of a field) 
+ repeat the last lrc justification (ex. lr+ == lrrrrrr... ) 
: treat the rest of the line as a field; acts as a modifier 
  to the last lrc. 
< left-justify the separator 
> right-justify the separator 
| center the separator 

These are, except for the ":", cyclic parameters. In other words, >< is equivalent to ><><><><... . Thus separators can be of differing lengths (ex. -+ as a separator pattern can match -, --, ---, etc and the separators will be left/right/center justified as you wish).

To get automatic, as-you-type, aligning of = in the C, vimL, and other languages, check out vimscript#884 for several ftplugins (which use Align).

Alternative Aligners: Gergely Kontra's vimscript#176

Thank you for rating Align!

DISCUSSION and COMMENTS:

Please use email for bugs. Enjoy!

(alpha/beta version available at http://mysite.verizon.net/astronaut/vim/index.html#ALIGN)

CDNJS是一个JS资料库,可以直接在网页上应用它上面拥有的一些JS文件。为什么不直接引用自己下载下来的库而要引用上面的文件呢?因为引用上面的文件可以使用户浏览网站的速度更佳,可以提高用户体验。Next主题的CDNJS直接调用的https://cdnjs.cloudflare.com, 按Next主题官方说法

Particularly, if you are a Chinese blogger or most of your visits come from China, please note that the CDNJS is blocked in some parts of China, don't use it as your CDN provider.

Next主题默认检测网站根目录安装的插件,将其视为内部的插件,对于某些未检测到的插件视为第三方插件。知道这个特性后,我们首先要做的就是安装@next-theme/plugins, 这样适配Next主题的特定插件就会在托管的网站内部加载,这可以保证Next的各项功能正常工作。操作如下:

1
2
diary --ThemeUpdate
npm install @next-theme/plugins

先更新Next主题的目的是匹配最新的@next-theme/plugins, 于是可以保证主题内部插件工作良好。然而Next主题的一些部分还采用了图标,这些图标并不在@next-theme/plugins范围内,其中最重要的local-search插件也会受到影响,所以需要加载CDN网站到第三方插件。目前国内有很多 NPM 的 CDN,可以支持相关包文件的高速访问下载,其中库比较全的CDN推荐以下三个:

其中Zstatic用到了镜像回源,也就是说只要访问一次,文件就会被存储到国内的服务器上,再也不用担心缓存过期了,所以网络文章建议优先用这个,但是在本博客主题上测试效果并不好。如果您使用 cdnjs.com 只需要替换 cdnjs.cloudflare.coms4.zstatic.net 即可,如

1
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
替换成
1
<script src="https://s4.zstatic.net/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

如果您使用 unpkg.com 只需要替换 unpkg.com 为 s4.zstatic.net/npm 即可,如

1
<script src="https://unpkg.com/react@16.7.0/umd/react.production.min.js"></script>
替换成
1
<script src="https://s4.zstatic.net/npm/react@16.7.0/umd/react.production.min.js"></script>

批量替换代码:

1
2
find . -type f -exec sed -i 's#https://unpkg.com#https://s4.zstatic.net/npm#g' {} +
find . -type f -exec sed -i 's#https://cdnjs.cloudflare.com#https://s4.zstatic.net#

  • Hexo Next主题在V8.19.0版本后就支持自定义cdnjs了,所以配置了s4.zstatic.net, 测试访问速度可以。2024年01月22日发现本博客的PDF组件无法使用,于是判断是s4.zstatic.net同步的js不全导致,更换为cdn.onmicrosoft.cnmirrors.sustech.edu.cn/cdnjs后问题解决,尽管在网络上看到文章推荐使用前者,但是在博客中表现来看后二者更佳,并且南科大镜像更加快速一些,完美适配了我的Next主题。
  • 2024年09月27日, 南方科技大学的cdn镜像访问出现问题,于是为保证网站正常访问不得不修复此问题。经过研究,安装@next-theme/plugins后,可以保证PDFNext主题依赖的插件由站内加载,其他部分则由cdn镜像加载,于是多数的镜像均可以正常使用了,为确保访问的稳定重新切换为s4.zstatic.net, 经测试效果良好.

在学会使用GitLab写博客之后,一直工作良好,但是今天发现仓库越来越大,编写博客时速度也越来越慢,原因在于每次commit后git都会形成一个快照,于是除了必备的Hexo部分外这个.git文件夹也是变的越来越大,这个才是导致仓库变大的主要原因,而作为写博客来讲,我是不需要使用commit切换回某个状态的,于是决定重置一下仓库。

  1. 创建新分支

    1
    git checkout --orphan latest

    使用--orpha选择,可创建1个无任何提交历史的清洁分支。新分支可以随意命名,但不要与以前的名冲突,只是网上乱七八糟的文章都相互抄袭,使用master而己,这是github的默认命名,而gitlab的默认名就是main.

  2. 添加所有文件

    1
    2
    3
    git add . 
    or
    git add -A

  3. commit代码

    1
    git commit -m "重置仓库"

  4. 删除原来的主分支(main)

    1
    git branch -D main

  5. 将当前分支重命名为main

    1
    git branch -m main

  6. 推送代码到远程仓库

    1
    2
    git branch --set-upstream-to=origin/main main
    git push -f origin main

    注意:默认gitlab开启了main分支保护,不允许强制push, 此时需要在远程仓库项目时暂时把项目保护关闭才能推送。关闭项目保护的方法: SettingsRepositoryProtected Branches , 在强推成功后一定要重新添加分支受保护。

  7. 从远程拉取新代码(测试之用)

    1
    git pull
    如果别人pull不下来,可以执行
    1
    git pull -r

  8. 确定清除历史记录的结果

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    # 查看提交日志
    git log --pretty=oneline
    # 查看分支信息
    # 列出所有本地分支
    $ git branch
    # 列出所有远程分支
    $ git branch -r
    # 列出所有本地分支和远程分支
    # $ git branch -a

    # 查看 tag 信息
    # 查看本地标签
    git tag
    # 查看远程标签
    git ls-remote --tags

LaTeX 大型文档通常使用多文件方法用于组织项目文件,以方便快速定位、修改。一般来说,建议使用subfiles宏包来组织多文件的大型文档,简单易用。 standalone宏包则可以用来编制会议论文集,每篇文章都使用独立的导言区,以避免自定义命令冲突。

subfiles宏包

主文件

主文件与普通LaTeX差不多。只是需要引用subfiles宏包,使用subfile命令导入子文件。

main.tex 主文件
1
2
3
4
5
6
7
8
9
10
11
12
13
\documentclass{main}
\usepackage{subfiles} % 尽量置于导言区的最后
\graphicspath{{contents/images/}}

\title{文档标题}
\author{作者}
\date{}

\begin{document}
\maketitle
\subfile{contents/chp-01} % 导入第一章
\subfile{contents/chp-02} % 导入第二章
\end{document}
阅读全文 »

在使用vimnvim编译latex文件时,对于单个源文件,自然使用vim-latex插件足够应对,但是对于一个多合一文件,比如说一本书,这里会有一个主文件,然后各个章节分开来写,但是每次写一部分后都要切换到主文件编译,然后再回到当前章节文件编辑,这显然是十分低效率的。于是研究使用一键编译,在多合一文件时能够直接编译主文件,设计思路是:

  1. 建立一个文件夹,. 例如:特殊函数/特殊函数.tex

  2. 绑定'F10'映射到编译命令,使用shell命令截取文件夹的名称,也就获得了主文件的名称,进而直接编译就可以了,文件夹内的其他子文件就不用再管了。

  3. 映射设置,位于'~/.config/nvim/lua/plg/vim-latex.lua`中,相关部分设置为:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    --绑定快捷键
    vim.api.nvim_create_autocmd("FileType",{
    pattern = "tex",
    callback = function()
    -- 配置F4打开模板
    vim.api.nvim_set_keymap("n", "<F4>", ":TTemplate<CR>", {noremap = true, silent = true})
    -- 配置pdflatex编译,原vim-latex中使用\ll 默认 xelatex 编译
    vim.api.nvim_set_keymap("n", "<F6>", [[<cmd>!pdflatex % <CR>]], {noremap = true, silent = true})
    -- 配置F8编译 aux辅助文件,直接根据数据库生成文献引用, 注意使用%:t:r 截取文件名
    vim.api.nvim_set_keymap("n", "<F8>", [[<cmd>!bibtex %:t:r.aux <CR>]], {noremap = true, silent = true})
    -- 配置F10编译多合一文件时,以当前目录名为主文件,以节省时间
    vim.api.nvim_set_keymap("n", "<F10>", [[<cmd>!xelatex $(echo $PWD|awk -F"/" '{print $NF}').tex <CR>]], {noremap = true, silent = true})
    end
    })

  4. 多合一文件的结构参考

    特殊函数
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    \documentclass[a4paper,fontset = windows]{ctexbook}
    \usepackage{xeCJKfntef}
    \usepackage[svgnames]{xcolor}
    \usepackage[margin=2cm]{geometry}
    \usepackage{tikz}
    \usetikzlibrary{patterns}
    \usepackage{float}
    \usepackage{amsfonts}
    \usepackage{amssymb}
    \usepackage{mathtools}
    \usepackage{amsthm}
    \usepackage{amsmath}
    \usepackage{physics}
    \usepackage{multicol}
    \usepackage{lineno}
    %\usepackage{mathpazo}
    \usepackage[
    pdfborder=0 0 0,
    bookmarksnumbered=true
    ]{hyperref}
    \usepackage[user=teacher]{cexam}
    \usepackage{colornote}
    \usepackage[fontwarning=off]{ctrlwarning}
    \usepackage{pgfplots}
    \pgfplotsset{compat=1.18}
    %\usepackage{doc}
    %\usepackage{draftwatermark}
    %\SetWatermarkText{冯振华}
    \includeonly{
    Gamma函数,
    Reimannζ函数,
    常系数线性微分方程,
    特殊函数的微分解法,
    积分变换,
    特殊函数的积分解法,
    Whittaker,
    椭圆函数,
    不等式高级水平必备,
    线性代数,
    张量分析,
    附录,
    }
    \begin{document}
    %\title{\Huge 特殊函数新解}
    %\author{ 冯振华}
    %\date{2020年12月3日}
    %\maketitle
    \input{coverpage}
    \tableofcontents
    \include{Gamma函数}
    \include{Reimannζ函数}
    \include{常系数线性微分方程}
    \include{特殊函数的微分解法}
    \include{积分变换}
    \include{特殊函数的积分解法}
    \include{Whittaker}
    \include{椭圆函数}
    \include{不等式高级水平必备}
    \include{线性代数}
    \include{张量分析}
    \include{附录}
    \end{document}

注意:在绑定到F10的编译命令中,本来应当借助于vimscript的内置变量,但是%:h返回值是当前目录的缩写., 而我需要的是和主文件同名的文件夹名,同时也没有使用shell截取字符串的方法,因为##%都被vimscript解析成它的命令用来替换,所以直接使用了awk来截截取文件夹名,从而也获得了主文件的名称。同时注意,由于使用了主文件/主文件.tex的命名方式,在多文件latex的编辑过程中,应当遵守这个规定命名。同时键位F9已经分配给了nabla插件,用来显示公式,所以此处多合一编辑分配了最后一个键位F10