如题:
本人OS信息:
物理机 windows10 pro 22H2 操作系统内部版本19045.5487
基于WSL2 下载了Ubuntu22.04
并且按照install-latex-guide-zh-cn的有关配置设置环境变量后,可以在WSL内正常使用tex -v
:
explorer@DESKTOP-Explorer:/mnt/c/Users/Explorer$ tex -v
TeX 3.141592653 (TeX Live 2025)
kpathsea version 6.4.1
Copyright 2025 D.E. Knuth.
There is NO warranty. Redistribution of this software is
covered by the terms of both the TeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the TeX source.
Primary author of TeX: D.E. Knuth.
同时在WSL
的终端下使用texdoc -help
可以弹出以下的内容:
explorer@DESKTOP-Explorer:/mnt/c/Users/Explorer$ texdoc -h
Usage: texdoc [OPTION]... NAME...
or: texdoc [OPTION]... ACTION
Try to find appropriate TeX documentation for the specified NAME(s).
Alternatively, perform the given ACTION and exit.
Options:
-w, --view Use view mode: start a viewer. (default)
-m, --mixed Use mixed mode (view or list).
-l, --list Use list mode: show a list of results.
-s, --showall Use showall mode: show also "bad" results.
-i, --interact Use interactive menus. (default)
-I, --nointeract Use plain lists, no interaction required.
-M, --machine Machine-readable output for lists (implies -I).
-q, --quiet Suppress warnings and most error messages.
-v, --verbose Print additional information (e.g., viewer command).
-D, --debug Activate all debug output (equal to "--debug=all").
-d LIST, --debug=LIST
Activate debug output restricted to LIST.
-c NAME=VALUE Set configuration item NAME to VALUE.
下略...
但是在WSL的终端使用texdoc lshort
却似乎因为没有图形化界面设置默认打开pdf的软件,在等待大约30s之后,弹出:
texdoc warning: No viewer defined for ".pdf" files, using "viewer_txt" instead.
我又尝试了在windows的终端使用wsl.exe texdoc lshort
,却提示:
master> wsl texdoc lshort
/bin/bash: line 1: texdoc: command not found
我不太理解的是,我是否应该把上述的环境变量不止写入.profile
(如下图),同时也应该写入.bashrc
呢?这里的$PATH
,.profile
以及.bashrc
被bash
终端调用的先后逻辑是什么?
或者换句话说,我只希望将“编译”这件事移到WSL内,“查看文档、编辑代码”都希望在物理机windows内进行,是否有比较完善的方案呢?
另附~/.profile
的文件内容:
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
# TeXLive2025 environment config
export PATH=/usr/local/texlive/2025/bin/x86_64-linux:$PATH
export MANPATH=/usr/local/texlive/2025/texmf-dist/doc/man:$MANPATH
export INFOPATH=/usr/local/texlive/2025/texmf-dist/doc/info:$INFOPATH
...我小丑了,我一直看的第二章和附录B
我是铸币,非常感谢OsbertWang老师编写的文档和@u686 楼主的帮助!