Obsdian导出增强配置

配置插件及工具

  1. Pandoc:万能文档格式转换工具,可以从http://pandoc.org下载。
  2. Obsdian导出增强(Enhancing Export)插件,这个是目前最好用的Obsdian导出插件。

导出PDF文件

PDF引擎

  1. 建议Windows下建议使用MiKTeXhttps://mirror.tuna.tsinghua.edu.cn/help/CTAN/,建议定期更新宏包(否则会出一些莫名其妙的问题)。可以再MiKTex Console上设置Proxy,更新时可以选择国内源进行更新。
  2. 在Obsdian导出增强插件中配置自定义参数,设置 --pdf-engine=xelatex ,即PDF引擎为xelatex

Pandoc表格插件

  1. Pandoc导出PDF文件时,如果表格比较大,表格内容则会溢出PDF文件导致表格显示不全,可以默认开启Pandoc表格插件功能。
  2. 可以在Pandoc参数中增加表格插件,可参考https://pandoc.org/MANUAL.html#extension-multiline_tables,此外还有grid_tables等表格插件。
  3. Pandoc参数为:-f markdown+multiline_tables

导出PDF模板(可选)

  1. 推荐使用eisvogel模板,详细下载地质https://github.com/Wandmalfarbe/pandoc-latex-template,作者持续在更新模板。
  2. 将现在好的模板可以放到用户目录下或者放到Obsdian附件目录
  3. Pandoc参数为:--template=eisvogel, 如果模板不是在默认的用户目录还需要指定具体模板路径。

中文字体

PDF模板和引擎对中文支持不好,需要通过强制指定中文字体解决。具体参数如下:

-V mainfont="Microsoft Yahei" -V CJKmainfont="Microsoft Yahei"
应用程序或者插件会将参数拼接成完整的Pandoc导出命令,如果应用程序有Bug可能将有空格的参数截断,导致最终拼接导出命令错误。例如Typora会将上述“Microsoft Yahei”从空格处截断,此时可将可在空格前加转义字符“\”,将命令修改成:-V mainfont="Microsoft\ Yahei" -V CJKmainfont="Microsoft\ Yahei"
当然,也可以选择其他不带空格的字体。

导出Word文件

导出Word文件相对配置简单一些,可以直接使用默认命令;如果导出Word样式不满意,可以指定导出Word模板。
--reference-doc="/path/templates.doc"

比较舒服的Word模板可以参考:https://github.com/Achuan-2/pandoc_docx_template,当然也可以基于上述模板二次修改成自己喜欢的。

Obsidian + Slides Extended 打造Markdown演示文稿

插件介绍

Slides extended是Obsdian一个演示文稿插件,支持用Markdown书写基于Reveal.js的演示文稿。非常适合快速输出教学演示文稿。
Sildes extended是最早是由MSzturc开发的Advacned Silde<github.com/MSzturc/obsidian-advanced-slides>插件,24年以后原作者不再更新后Erin fork出后以Slides Extendedhttps://github.com/ebullient/obsidian-slides-extended继续开发。

Slides extended是目前遇到的最好用的Markdown写演示文稿的工具。当前唯一的缺点是不能直接导出PPT格式,这个估计需要reveal.js支持才能支持。

插件的详细介绍参考

https://mszturc.github.io/obsidian-advanced-slides/

配合使用模板和布局可以预配置好演示文稿的布局风格,日常写作时专注于文件本身。

https://mszturc.github.io/obsidian-advanced-slides/templates/
https://mszturc.github.io/obsidian-advanced-slides/layout/

Linux 文件权限简记

数字权限使用格式

在这种使用方式中,首先我们需要了解数字如何表示权限。 首先,我们规定 数字 4 、2 和 1表示读、写、执行权限,即 r=4,w=2,x=1 。此时其他的权限组合也可以用其他的八进制数字表示出来,

如:

1
2
3
rwx = 4 + 2 + 1 = 7
rw = 4 + 2 = 6
rx = 4 +1 = 5

即:

  • 若要同时设置 rwx (可读写运行) 权限则将该权限位 设置 为 4 + 2 + 1 = 7
  • 若要同时设置 rw- (可读写不可运行)权限则将该权限位 设置 为 4 + 2 = 6
  • 若要同时设置 r-x (可读可运行不可写)权限则将该权限位 设置 为 4 +1 = 5

命令格式 chmod [可选项] <mode> <file…>

2025-08-31-18

在WSL中安装NixOS

Install NixOS-WSL

First, download nixos.wsl from the latest release.1 https://github.com/nix-community/NixOS-WSL/releases/tag/2505.7.0

If you have WSL version 2.4.4 or later installed, you can open (double-click) the .wsl file to install it. It is also possible to perform the installation from a PowerShell:

1
wsl --install --from-file nixos.wsl

nixos.wsl must be the path to the file you just downloaded if you’re running the command in another directory.

You can use the --name and --location flags to change the name the distro is registered under (default: NixOS) and the location of the disk image (default: %localappdata%\wsl\{some random GUID}). For a full list of options, refer to wsl --help

To open a shell in your NixOS environment, run wsl -d NixOS, select NixOS from the profile dropdown in Windows Terminal or run it from your Start Menu. (Adjust the name accordingly if you changed it)

  • 参考资料

https://nix-community.github.io/NixOS-WSL/install.html

配置vscode远程访问

The VSCode Remote server can not be run as-is on NixOS, because it downloads a nodejs binary that requires /lib64/ld-linux-x86-64.so.2 to be present, which isn’t the case on NixOS.

There are two options to get the server to run. Option 1 is more robust but might impact other programs. Option 2 is a little bit more brittle and sometimes breaks on updates but doesn’t influence other programs. Both options require wget to be installed:

1
2
3
environment.systemPackages = [
pkgs.wget
];

Option 1: Set up nix-ld
nix-ld is a program that provides /lib64/ld-linux-x86-64.so.2, allowing foreign binaries to run on NixOS.

To set it up, add the following to your configuration:

programs.nix-ld.enable = true;

  • 参考资料

https://nix-community.github.io/NixOS-WSL/how-to/vscode.html

Linux下如何修改分区Label

如何修改Linux分区标签Label

安装系统时如果没有为分区打标签,正常启动启动后不同文件管理器会显示对分区显示不同的名称。有的文件管理器会隐藏系统分区,显示其他分区类型(同一类分区类型特别容易误操作)。因此可以根据自己分区用途来设定不同的分区标签。

  • 查询系统分区情况
    lsblk -o name,mountpoint,label,size,uuid

  • 修改ntfs分区标签

    需要先安装ntfs3g软件,再通过ntfslabel命令修改;

  • 修改btrfs分区标签
    sudo btrfs filesystem label / NixOS

  • 修改ext3/ext4分区标签
    e2label device newlabel

Linux下如何修改分区Label

如何修改Linux分区标签Label

安装系统时如果没有为分区打标签,正常启动启动后不同文件管理器会显示对分区显示不同的名称。有的文件管理器会隐藏系统分区,显示其他分区类型(同一类分区类型特别容易误操作)。因此可以根据自己分区用途来设定不同的分区标签。

  • 查询系统分区情况
    lsblk -o name,mountpoint,label,size,uuid

  • 修改ntfs分区标签

    需要先安装ntfs3g软件,再通过ntfslabel命令修改;

  • 修改btrfs分区标签
    sudo btrfs filesystem label / NixOS

  • 修改ext3/ext4分区标签
    e2label device newlabel

nix-rebuild命令

nix-rebuil命令

1
2
3
4
5
6
7
nixos-rebuild {switch | boot | test | build | dry-build | dry-activate | edit | build-vm | build-vm-with-bootloader}
[{ --upgrade | --upgrade-all }] [--install-bootloader] [--no-build-nix] [--fast] [--rollback] [--builders builder-spec]
[--flake flake-uri] [--override-input input-name flake-uri]
[{ --profile-name | -p } name]
[--build-host host] [--target-host host] [--use-remote-sudo]
[--show-trace] [-I path] [{--verbose | -v}] [{--impure}] [{--max-jobs | -j} number] [{--keep-failed | -K}] [{--keep-going | -k}]

几个常见的命令

1
2
3
4
5
nixos-rebuild list-generations
sudo nix-collect-garbage -d
sudo nixos-rebuild boot
sudo nixos-rebuild switch -p profile-name

其中最后一条命令详解如下:

1
2
3
4
5
6
7
8
9
10
--profile-name,  -p

Instead of using the Nix profile /nix/var/nix/profiles/system to keep track of the current and previous system configurations, use /nix/var/nix/profiles/system-profiles/name. When you use GRUB 2, for every system profile created with this flag, NixOS will create a submenu named “NixOS - Profile 'name'” in GRUB’s boot menu, containing the current and previous configurations of this profile.

For instance, if you want to test a configuration file named test.nix without affecting the default system profile, you would do:

$ nixos-rebuild switch -p test -I nixos-config=./test.nix

The new configuration will appear in the GRUB 2 submenu “NixOS - Profile 'test'”.

可以在/nix/var/nix/profiles/system-profiles/ 目录下找到标签相关的文件,删除掉标签目录,重新执行一次sudo nixos-rebuild boot 就可以删除标签相关grub启动项目。

阅读更多

安装nixos后要做的事情

更新channel源

1
2
sudo nix-channel --add https://mirrors.tuna.tsinghua.edu.cn/nix-channels/nixos-24.11 nixos
sudo nix-channel --update

注意修改nixos-24.11到匹配的版本

启用flatpak

  1. /etc/nixos/configuration.nix中添加如下代码,启用flatpak
1
2
3
4
# flatpak support
xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-kde ];
xdg.portal.enable = true;
services.flatpak.enable = true;
  1. 启用蓝牙
1
2
hardware.bluetooth.enable = true; # enables support for Bluetooth
hardware.bluetooth.powerOnBoot = true; # powers up the default Bluetooth controller on boot
  1. 启用系统级工具
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 允许安装unfree包
nixpkgs.config.allowUnfree = true;
# 安装常用的软件包
environment.systemPackages = with pkgs; [
vim
wget
pkgs.git
pkgs.nodejs_20
pkgs.texliveSmall
cpkgs.hexo-cli
pkgs.pandoc
pkgs.vscode
pkgs.microsoft-edge

];
  1. 安装字体及输入法
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
i18n.inputMethod = {

enable = true;
type = "fcitx5";
fcitx5.addons = with pkgs; [
fcitx5-gtk # alternatively, kdePackages.fcitx5-qt
fcitx5-chinese-addons # table input method support
fcitx5-nord # a color theme
fcitx5-fluent
fcitx5-material-color
rime-data
fcitx5-rime
];

};

fonts = {
packages = with pkgs; [
noto-fonts
noto-fonts-cjk-sans
noto-fonts-cjk-serif
source-code-pro
hack-font
jetbrains-mono
];
};

  1. 配置网络
1
2
3
4
5
6
7
8
9
# Enable networking
networking.networkmanager.enable = true;
networking.networkmanager.dns = "none";
networking.nameservers = [
"223.5.5.5"
"8.8.8.8"
"114.114.114.114"
];

  1. 更新系统执行sudo nixos-rebuild switch更新系统

  2. 修改flatpak源,并安装常用软件

1
2
3
4
sudo flatpak remote-modify flathub --url=https://mirrors.ustc.edu.cn/flathub

flatpak install flathub md.obsidian.Obsidian

阅读更多

Pandoc将Markdown文件导出成PDF文件

Pandoc将Markdown文件转换成PDF文件时是先将Markdown文件转换成Latex文件,再将Latex文件专程PDF文件。参考命令:

1
pandoc example.md -o example.pdf --from markdown --pdf-engine=xelatex --template=eisvogel --listings

选择编译引擎

一般默认的编译引擎是pdflatex编译引擎,这个引擎对中文支撑不太友好,可以通过–pdf-engine=xelatex 修改编译引擎。

选择模板

使用pandoc模板 eisvogel ,eisvogel可以导出很漂亮的PDF文件。

  1. 将 eisvogel 模板拷贝到pandoc用户模板目录下,具体配置:

    • 在Linux系统下:/home/USERNAME/.local/share/pandoc/templates/
    • 在Windows系统下:C:\Users\USERNAME\AppData\Roaming\pandoc\templates\
  2. 改善中文支持,需要在eisvogel添加如下参数:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    \else % if not pdftex
    $if(mainfont)$
    $else$
    \usepackage[fallback]{xeCJK}
    \setCJKmainfont{SimSun}[BoldFont=SimHei, ItalicFont=KaiTi] %配置中文字体
    \setCJKfallbackfamilyfont{rm}{SimSun}
    \usepackage[default]{sourcesanspro}
    \usepackage{sourcecodepro}

  3. 增加首行缩进,在 eisvogel.tex 文件中查找,在\begin{document}请增加一段代码:

    1
    2
    3
    4
    \usepackage{ctex} %调用中文字体宏包
    \usepackage{indentfirst} %调用首行缩进宏包
    \setlength{\parindent}{2em} %设置首行缩进为2字符
    \begin{document}
阅读更多