Docker中创建latex和sphinx文档环境
- 配置容器系统环境
- archlinux基础镜像版本1.0
- 配置sphinx文档生成环境
- 配置sphinx
- 使用sphinx
- 配置latex文档生成环境
- 配置latex环境
- 安装texlive
- 配置VSCODE并生成latex文档
配置容器系统环境
# >宿主机
# 1. 拉取镜像
docker pull archlinux
# 2. 启动容器,进入bash
docker run -it --name www.qicz.com archlinux:latest /bin/bash
# >宿主机结束# >容器
# 备份镜像服务地址
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.back
# 修改镜像服务为清华大学镜像源,注意$转义
echo Server = https://mirrors.tuna.tsinghua.edu.cn/archlinux/\$repo/os/\$arch > /etc/pacman.d/mirrorlist
# 更新缓存、系统、软件
pacman -Syyu
# 安装vim sudo
pacman -S vim sudo# 创建qicz用户,并创建家目录
useradd -m qicz
# 修改用户密码
passwd qicz# 修改sudo文件,使qicz可以使用sudo
vim /etc/sudoers
# 增加 qicz ALL=(ALL:ALL) ALL
# 切换到qicz用户
su qicz
# 安装zsh和git
sudo pacman -S zsh git
# 拉取oh-my-zsh
git clone https://gitee.com/mirrors/oh-my-zsh.git
# 修改onmyzsh安装脚本`oh-my-zsh/tools/install.sh`中远端仓库地址,加速安装。
# REPO=${REPO:-mirrors/oh-my-zsh}
# REMOTE=${REMOTE:-https://gitee.com/${REPO}.git}# 安装主题
oh-my-zsh/tools/install.sh#切换shell程序
chsh -s /bin/zsh#修改zsh用户配置文件`~/.zshrc`,中的`ZSH_THEME="ys"`以使用新的主题。#退出容器
exit
exit
exit
# >容器结束
archlinux基础镜像版本1.0
# >宿主机
# 停止容器运行
docker stop www.qicz.com
# 提交容器版本
docker commit -m "提交archlinux基础镜像" www.qicz.com archlinuxbase:1.0
# 删除旧的容器
docker container rm www.qicz.com
# >宿主机结束
配置sphinx文档生成环境
配置sphinx
# >宿主
# 启动容器,进入/bin/zsh,指定用户qicz,设置映射工作文件夹
docker run -it --name www.qicz.com -u qicz -v ~/Workspace:/home/qicz/Workspace archlinuxbase:1.0 /bin/zsh
# >宿主机结束# >容器
# 安装sphinx,python-virtualenv
sudo pacman -S python python-virtualenv
# 创建env
python -m venv .python_sphinx
# 配置pip使用清华大学镜像源
vim ~/.pip/pip.conf
#[global]
#index-url = https://pypi.tuna.tsinghua.edu.cn/simple
# 进入.python_sphinx启动虚拟环境
source .python_sphinx/bin/activate
# 升级pip
pip install --upgrade pip
# 安装sphinx
pip install -U m2r2 setuptools sphinx
#安装sphinx-tags
pip install -U sphinx-tags
#退出容器
exit
exit
exit
# >容器结束
使用sphinx
# >宿主
# 如果没有启动docker服务,启动
sudo systemctl start docker
# 启动容器,进入/bin/zsh,指定用户qicz,设置映射工作文件夹
docker run -it --name www.qicz.com -u qicz -v ~/Workspace:/home/qicz/Workspace archlinuxbase:1.0 /bin/zsh
# 如果已经启动容器,开启即可
docker start www.qicz.com
docker exec -it www.qicz.com /bin/zsh
# >宿主机结束# >容器
# 进入.python_sphinx启动虚拟环境
source .python_sphinx/bin/activate
# 生成文档
sphinx-build source build#退出容器
exit
exit
exit
# >容器结束
配置latex文档生成环境
配置latex环境
安装texlive
# >宿主
# 启动容器,进入/bin/zsh,指定用户qicz,设置映射工作文件夹
docker run -it --name www.qicz.com -u qicz -v ~/Workspace:/home/qicz/Workspace archlinuxbase:1.0 /bin/zsh
# >宿主机结束# >容器
# 安装textlive-*
sudo pacman -S texlive-basic texlive-bibtexextra texlive-bin texlive-binextra texlive-context texlive-doc texlive-fontsextra texlive-fontsrecommended texlive-fontutils texlive-humanities texlive-langarabic texlive-langchinese texlive-langenglish texlive-langjapanese texlive-latex texlive-xetex
# 或者完整安装
sudo pacman -S texlive-basic texlive-bibtexextra texlive-bin texlive-binextra texlive-context texlive-doc texlive-fontsextra texlive-fontsrecommended texlive-fontutils texlive-formatsextra texlive-games texlive-humanities texlive-langarabic texlive-langchinese texlive-langcjk texlive-langcyrillic texlive-langczechslovak texlive-langenglish texlive-langeuropean texlive-langfrench texlive-langgerman texlive-langgreek texlive-langitalian texlive-langjapanese texlive-langkorean texlive-langother texlive-langpolish texlive-langportuguese texlive-langspanish texlive-latex texlive-latexextra texlive-latexrecommended texlive-luatex texlive-mathscience texlive-meta texlive-metapost texlive-music texlive-pictures texlive-plaingeneric texlive-pstricks texlive-publishers texlive-xetex
# 配置windows字体
cp -r ~/Workspace/winfonts ~/
mkdir -p ~/.local/share/fonts/winfonts
cp ~/Workspace/winfonts/* ~/.local/share/fonts/winfonts/
fc-cache -fv#退出容器
exit
exit
exit
# >容器结束
配置VSCODE并生成latex文档
安装Dev Containers插件
连接容器
安装远程vscode插件Latex Workshop
打开要预览的tex文档,生成pdf