2025年7月

安装 Pandoc

Pandoc 是一个文档转换工具,可以实现 mddocxpdf

Sudo pacman -Syu pandoc

安装 TexLive

使用 Tex 的核心组件,安装 Arch Linux 中的包组 texlive 即可。

sudo pacman -Syu texlive

LaTex 使用示例

编写 test.tex 文件:

\documentclass{article}
\begin{document}
Hello World!
\end{document}

编译:

latex test.tex

查看:

xdvi test.dvi

也可以直接生成 pdf 文件:

pdflatex test.tex

详细教程参考WIKI

Pandoc 使用示例

创建了一个样例文件 sample.md

# Sample Markdown Document

This is a **comprehensive sample** of Markdown syntax to test conversion tools like *Pandoc*. It includes headings, lists, code, blockquotes, tables, links, images, footnotes, math, and more.

---

## Table of Contents

1. [Headings](#headings)
2. [Text Formatting](#text-formatting)
3. [Lists](#lists)
4. [Blockquotes](#blockquotes)
5. [Code](#code)
6. [Tables](#tables)
7. [Links & Images](#links--images)
8. [Footnotes](#footnotes)
9. [Horizontal Rules](#horizontal-rules)
10. [Math](#math)
11. [HTML](#html)
12. [Task Lists](#task-lists)

---

## Headings

# H1 Heading  
## H2 Heading  
### H3 Heading  
#### H4 Heading  
##### H5 Heading  
###### H6 Heading  

---

## Text Formatting

- **Bold**
- *Italic*
- ***Bold and Italic***
- ~~Strikethrough~~  
- <u>Underline (via HTML)</u>  
- ==Highlight (not native, Pandoc-supported)==  
- `Inline code`

---

## Lists

### Unordered List

- Item A  
  - Subitem A.1  
    - Sub-subitem A.1.a
- Item B

### Ordered List

1. First item
2. Second item  
   a. Subitem  
   b. Another subitem  
3. Third item

---

## Blockquotes

> This is a blockquote.  
> 
> > Nested blockquote.  
>
> Another line in the same quote.

---

## Code

### Inline Code

Use the `printf()` function.

### Fenced Code Blocks

def greet(name):

print(f"Hello, {name}!")

!/bin/bash

echo "Hello, world"

console.log("Hello, JavaScript!");


---

## Tables

| Syntax | Description | Output |
|--------|-------------|--------|
| Header | Title       | Text   |
| `code` | *Italic*    | **Bold** |

Right-aligned:

| ID | Name    | Score |
|----|---------|------:|
| 1  | Alice   |    90 |
| 2  | Bob     |    85 |
| 3  | Charlie |    95 |

---

## Links & Images

### Link

[OpenAI](https://www.openai.com)  
<https://www.example.com>

### Image

![Markdown Logo](https://upload.wikimedia.org/wikipedia/commons/4/48/Markdown-mark.svg)

---

## Footnotes

Here is a sentence with a footnote.[^1]

[^1]: This is the footnote definition.

---

## Horizontal Rules

---

---

## Math

Inline: $E = mc^2$

Block:

$$
\int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2}
$$

---

## HTML

<div style="color: blue;">
This is an HTML block inside Markdown.
</div>

---

## Task Lists

- [x] Write a sample file  
- [x] Include all major syntax  
- [ ] Test with Pandoc  
- [ ] Export to PDF/HTML/Docx  

---

_End of document._

---

## 中文测试段落

这是一个用于测试 **Pandoc** 是否支持中文的段落。

中文支持对于中文用户来说非常重要。你可以尝试将此文档导出为 PDF 或 DOCX,看看字体是否正常显示、排版是否美观。

以下是一些常见的中文格式测试:

- **加粗文字**
- *斜体文字*
- ~~删除线文字~~
- `行内代码`

### 中文列表

1. 第一步:安装 Pandoc;
2. 第二步:准备 Markdown 文件;
3. 第三步:运行转换命令。

- 项目 A
  - 子项目 A.1
- 项目 B

### 中文段落示例

在很久很久以前,有一个叫做 Markdown 的标记语言,它简洁、优雅、易于使用。在中文世界中,它也越来越受欢迎。

> “生活就像一盒巧克力,你永远不知道你会得到什么。” ——《阿甘正传》

---

_测试结束。_

直接转换成 pdf ,显示效果可能不太好。

pandoc -o sample.pdf sample.md

在网上抄来的一套配置,首先在根目录创建 head.tex

\usepackage[top=2cm, bottom=1.5cm, left=2cm, right=2cm]{geometry}
% change background color for inline code in
% markdown files. The following code does not work well for
% long text as the text will exceed the page boundary
\definecolor{bgcolor}{HTML}{E0E0E0}
\let\oldtexttt\texttt

\renewcommand{\texttt}[1]{
    \colorbox{bgcolor}{\oldtexttt{#1}}
}

\XeTeXlinebreaklocale "zh"
\XeTeXlinebreakskip = 0pt plus 1pt minus 0.1pt
\usepackage[top=2cm, bottom=1.5cm, left=2cm, right=2cm]{geometry}

% Change the default style of block quote

\usepackage{framed}
\usepackage{quoting}

\definecolor{bgcolor}{HTML}{DADADA}
\colorlet{shadecolor}{bgcolor}
% define a new environment shadedquotation. You can change leftmargin and
% rightmargin as you wish.
\newenvironment{shadedquotation}
{\begin{shaded*}
     \quoting[leftmargin=1em, rightmargin=0pt, vskip=0pt, font=itshape]
     }
     {\endquoting
\end{shaded*}
}

%
\def\quote{\shadedquotation}
\def\endquote{\endshadedquotation}

随后使用命令:

pandoc --pdf-engine=xelatex -V mainfont='Source Han Serif CN' --highlight-style tango -V colorlinks=true -o output.pdf sample.md -H head.tex

效果稍微好一点。

安装 Docker Engine

参考官方文档:官方文档(Ubuntu)

配置代理

由于 Docker 的守护进程不走系统代理,按官方文档的方法安装完后,会发现sudo docker run hello-world连接超时。

同样参考官方文档:官方文档

注意!后来发现在其他设备按照官方文档的方法配置没能成功,问GPT后解决:

官方文档写法:

[Service]
Environment="HTTP_PROXY=http://proxy.example.com:3128"
Environment="HTTPS_PROXY=https://proxy.example.com:3129"
Environment="NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp"

实际上在第二项Environment="HTTPS_PROXY=https://proxy.example.com:3129"这里,如果使用Clash的局域网代理,要把https改成http,例如:

[Service]
Environment="HTTP_PROXY=http://192.168.0.104:7897"
Environment="HTTPS_PROXY=http://192.168.0.104:7897"
Environment="NO_PROXY=localhost,127.0.0.1"

至于如何配置系统代理,参考Ubuntu Server 静态IP与网络代理设置

拿家里旧电脑装了一台 Ubuntu 服务器,记录如何初始化网络设置。

Screenshot_20250711_231617.png

静态IP设置

在安装过程中,选择手动配置IPv4(Manual),随后按以下配置填写:

// 此为网络号+子网掩码
Subnet: 192.168.0.0/24

// 此为分配给该机的IP地址,选个没用过的即可
Address: 192.168.0.150

// 网关,局域网下另一台机器查一下即可
Gateway: 192.168.0.1

// 名称服务器,同上
Name servers: 192.168.0.1

网络代理设置

在一台有网络代理的机器上,打开代理软件中的“局域网连接”选项。

确定本机IP,如192.168.0.104;确定代理软件所用端口,如7897。

随后在服务器上运行如下命令:

export http_proxy=http://192.168.0.104:7897
export https_proxy=http://192.168.0.104:7897

此为一次性命令,想永久生效加入.bashrc即可。

验证是否配置成功

运行如下命令:

curl -I https://www.google.com

做 LeetCode Q56 时遇到的问题:56. 合并区间

跟 C++ 里的 cmp 差不多,三种写法。

假如有二维数组

int[][] intervals = new int[n][2];

现在要以每行的第一列为主键排序。

一、匿名内部类

Arrays.sort(intervals, new Comparator<int[]>() {
    public int compare(int[] a, int[] b) {
        return a[0] - b[0]; // 升序
    }
});

二、 Lambda 表达式

Java 8 之后可以简写为:

Arrays.sort(intervals, (a, b) -> a[0] - b[0]);

三、实现 Comparator 接口的类

class IntervalComparator implements Comparator<int[]> {
    public int compare(int[] a, int[] b) {
        return a[0] - b[0];
    }
}

// 使用
Arrays.sort(intervals, new IntervalComparator());

说实话,并没有完全理解 :(

此博客仅作记录,对可靠性和正确性不作保证。

遇到问题多查 arch wiki

Arch Linux 中文社区

下载 archlinux 系统镜像并制作系统盘

  • 前往 Arch Linux 官网下载系统镜像;
  • 使用系统盘制作工具(如rufus)制作系统盘;
  • 插上系统盘,重启电脑进入bios,修改启动顺序为系统盘最优先;
  • 启动,选择安装 archlinux。

安装 archlinux (使用 archinstall)

整盘安装直接参考BV1jys6eaEtM

双系统安装可参考BV1qK42187Jp(主要是分区和挂载的部分)

安装火狐浏览器

不得不说还是 Arch 简洁,自带浏览器都没有。

sudo pacman -Syu firefox

安装中文字体、中文输入法

安装中文字体(以思源宋体为例):

sudo pacman -Syu adobe-source-han-serif-cn-fonts

修改/etc/locale.gen

sudo vim /etc/locale.gen

将 zh_CN.UTF-8 前面的井号去掉。

安装中文输入法(使用fcitx5):

sudo pacman -Syu fcitx5-im fcitx5-chinese-addons

安装完在系统设置里配置一下。

添加 Arch Linux 中文社区仓库

由于众所周知的原因,我们在安装一些软件包的时候会遇到一些网络问题,Arch Linux 中文社区仓库可以提供一些帮助。

修改/etc/pacman.conf,将下面两行加在文件末尾:

[archlinuxcn]
Server = https://repo.archlinuxcn.org/$arch

随后执行:

sudo pacman -Sy archlinuxcn-keyring
sudo pacman -Su archlinuxcn-mirrorlist-git

本地化定制

利用 Arch Linux 中文社区仓库,可以搭建一套可供日常使用的体系。

安装yay,方便后续使用 AUR 包:

sudo pacman -Syu yay

安装clash-verg-rev,解决网络问题:

yay clash-verg-rev

安装QQ、微信:

yay linuxqq
yay wechat

其他

安装Visual Studio Code:

Arch 官方库里的并非微软官方版本,下为微软官方版本安装方法。

yay visual-studio-code-bin