├── .gitattributes ├── .github ├── dependabot.yml ├── tl_packages └── workflows │ ├── cache.yaml │ └── main.yaml ├── .gitignore ├── LICENSE ├── README.md ├── build.lua ├── chapter ├── addition.tex ├── editor.tex ├── macos.tex ├── mirror.tex ├── offline.tex ├── overleaf.tex ├── preface.tex ├── ubuntu.tex ├── updateinfo.tex ├── windows.tex └── wsl.tex ├── install-latex-guide-zh-cn.tex ├── make.bat └── makefile /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.tex text eol=lf 3 | .gitignore text eol=lf 4 | LICENSE text eol=lf 5 | *.bat text eol=crlf 6 | makefile text eol=lf 7 | *.md text eol=lf 8 | .gitattributes text eol=lf -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | # Check for updates to GitHub Actions every week 8 | interval: "daily" 9 | -------------------------------------------------------------------------------- /.github/tl_packages: -------------------------------------------------------------------------------- 1 | # The test framework itself 2 | l3build 3 | # 4 | # Base 5 | latex 6 | latex-bin 7 | # 8 | # For the doc target 9 | adjustbox 10 | booktabs 11 | ctex 12 | fancyqr 13 | fancyvrb 14 | fontawesome6 15 | geometry 16 | hologo 17 | hyperref 18 | ifoddpage 19 | latexmk 20 | libertine 21 | listings 22 | menukeys 23 | pict2e 24 | qrcode 25 | relsize 26 | xstring -------------------------------------------------------------------------------- /.github/workflows/cache.yaml: -------------------------------------------------------------------------------- 1 | # This workflow makes sure that there is always a cache present for the main branch. 2 | # This cache can be picked up by all other branches, so it ensures that even new 3 | # branches and tags don't have to download a complete copy of TeX Live. 4 | # 5 | # Since GitHub keeps unused caches for one week, we need to run at least once a week 6 | # to ensure that the cache always stays around. To avoid timing issues and issues 7 | # when an update fails for some reason, we run twice per week. 8 | 9 | name: Keep TeX Live cache up-to-date 10 | on: 11 | schedule: 12 | # Run every tuesday and saturday at 09:41. The time has been chosen at random. 13 | - cron: '41 9 * * 3,5' 14 | 15 | jobs: 16 | cache: 17 | strategy: 18 | matrix: 19 | os: [ubuntu-latest, macos-latest, windows-latest] 20 | runs-on: ${{ matrix.os }} 21 | name: Update TeX Live 22 | steps: 23 | # To use `.github/tl_packages`, main repo must be checked out first. 24 | - name: Checkout repository 25 | uses: actions/checkout@v4 26 | - name: Install TeX Live 27 | uses: zauguin/install-texlive@v4 28 | with: 29 | # List the required TeX Live packages in a separate file to allow reuse in 30 | # different workflows. 31 | package_file: .github/tl_packages -------------------------------------------------------------------------------- /.github/workflows/main.yaml: -------------------------------------------------------------------------------- 1 | name: Automated testing 2 | 3 | on: 4 | push: 5 | branches: 6 | - "**" 7 | pull_request: 8 | 9 | jobs: 10 | l3build: 11 | strategy: 12 | matrix: 13 | os: [ubuntu-latest, macos-latest, windows-latest] 14 | runs-on: ${{ matrix.os }} 15 | steps: 16 | - name: Checkout repository 17 | uses: actions/checkout@v4 18 | - name: Install TeX Live 19 | uses: zauguin/install-texlive@v4 20 | with: 21 | package_file: .github/tl_packages 22 | - name: Run l3build 23 | run: l3build ctan -q -H -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Core latex/pdflatex auxiliary files: 2 | *.aux 3 | *.lof 4 | *.log 5 | *.lot 6 | *.fls 7 | *.out 8 | *.toc 9 | *.fmt 10 | *.fot 11 | *.cb 12 | *.cb2 13 | .*.lb 14 | 15 | ## Intermediate documents: 16 | *.dvi 17 | *.xdv 18 | *-converted-to.* 19 | # these rules might exclude image files for figures etc. 20 | *.ps 21 | *.eps 22 | *.pdf 23 | 24 | 25 | ## Generated if empty string is given at "Please type another file name for output:" 26 | .pdf 27 | 28 | ## Bibliography auxiliary files (bibtex/biblatex/biber): 29 | *.bbl 30 | *.bcf 31 | *.blg 32 | *-blx.aux 33 | *-blx.bib 34 | *.run.xml 35 | 36 | ## Build tool auxiliary files: 37 | *.fdb_latexmk 38 | *.synctex 39 | *.synctex(busy) 40 | *.synctex.gz 41 | *.synctex.gz(busy) 42 | *.pdfsync 43 | /build 44 | *.curlopt 45 | *.zip 46 | 47 | ## Auxiliary and intermediate files from other packages: 48 | # algorithms 49 | *.alg 50 | *.loa 51 | 52 | # achemso 53 | acs-*.bib 54 | 55 | # amsthm 56 | *.thm 57 | 58 | # beamer 59 | *.nav 60 | *.pre 61 | *.snm 62 | *.vrb 63 | 64 | # changes 65 | *.soc 66 | 67 | # cprotect 68 | *.cpt 69 | 70 | # elsarticle (documentclass of Elsevier journals) 71 | *.spl 72 | 73 | # endnotes 74 | *.ent 75 | 76 | # fixme 77 | *.lox 78 | 79 | # feynmf/feynmp 80 | *.mf 81 | *.mp 82 | *.t[1-9] 83 | *.t[1-9][0-9] 84 | *.tfm 85 | 86 | #(r)(e)ledmac/(r)(e)ledpar 87 | *.end 88 | *.?end 89 | *.[1-9] 90 | *.[1-9][0-9] 91 | *.[1-9][0-9][0-9] 92 | *.[1-9]R 93 | *.[1-9][0-9]R 94 | *.[1-9][0-9][0-9]R 95 | *.eledsec[1-9] 96 | *.eledsec[1-9]R 97 | *.eledsec[1-9][0-9] 98 | *.eledsec[1-9][0-9]R 99 | *.eledsec[1-9][0-9][0-9] 100 | *.eledsec[1-9][0-9][0-9]R 101 | 102 | # glossaries 103 | *.acn 104 | *.acr 105 | *.glg 106 | *.glo 107 | *.gls 108 | *.glsdefs 109 | 110 | # gnuplottex 111 | *-gnuplottex-* 112 | 113 | # gregoriotex 114 | *.gaux 115 | *.gtex 116 | 117 | # htlatex 118 | *.4ct 119 | *.4tc 120 | *.idv 121 | *.lg 122 | *.trc 123 | *.xref 124 | 125 | # hyperref 126 | *.brf 127 | 128 | # knitr 129 | *-concordance.tex 130 | # TODO Comment the next line if you want to keep your tikz graphics files 131 | *.tikz 132 | *-tikzDictionary 133 | 134 | # listings 135 | *.lol 136 | 137 | # makeidx 138 | *.idx 139 | *.ilg 140 | *.ind 141 | *.ist 142 | 143 | # minitoc 144 | *.maf 145 | *.mlf 146 | *.mlt 147 | *.mtc[0-9]* 148 | *.slf[0-9]* 149 | *.slt[0-9]* 150 | *.stc[0-9]* 151 | 152 | # minted 153 | _minted* 154 | *.pyg 155 | 156 | # morewrites 157 | *.mw 158 | 159 | # nomencl 160 | *.nlg 161 | *.nlo 162 | *.nls 163 | 164 | # pax 165 | *.pax 166 | 167 | # pdfpcnotes 168 | *.pdfpc 169 | 170 | # sagetex 171 | *.sagetex.sage 172 | *.sagetex.py 173 | *.sagetex.scmd 174 | 175 | # scrwfile 176 | *.wrt 177 | 178 | # sympy 179 | *.sout 180 | *.sympy 181 | sympy-plots-for-*.tex/ 182 | 183 | # pdfcomment 184 | *.upa 185 | *.upb 186 | 187 | # pythontex 188 | *.pytxcode 189 | pythontex-files-*/ 190 | 191 | # thmtools 192 | *.loe 193 | 194 | # TikZ & PGF 195 | *.dpth 196 | *.md5 197 | *.auxlock 198 | 199 | # todonotes 200 | *.tdo 201 | 202 | # easy-todo 203 | *.lod 204 | 205 | # xmpincl 206 | *.xmpi 207 | 208 | # xindy 209 | *.xdy 210 | 211 | # xypic precompiled matrices 212 | *.xyc 213 | 214 | # endfloat 215 | *.ttt 216 | *.fff 217 | 218 | # Latexian 219 | TSWLatexianTemp* 220 | 221 | ## Editors: 222 | # WinEdt 223 | *.bak 224 | *.sav 225 | 226 | # Texpad 227 | .texpadtmp 228 | 229 | # Kile 230 | *.backup 231 | 232 | # KBibTeX 233 | *~[0-9]* 234 | 235 | # auto folder when using emacs and auctex 236 | ./auto/* 237 | *.el 238 | 239 | # expex forward references with \gathertags 240 | *-tags.tex 241 | 242 | # standalone packages 243 | *.sta 244 | 245 | # generated if using elsarticle.cls 246 | *.spl 247 | 248 | # garbage file in macOS 249 | *.DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The LaTeX Project Public License 2 | =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 3 | 4 | LPPL Version 1.3c 2008-05-04 5 | 6 | Copyright 1999 2002-2008 LaTeX3 Project 7 | Everyone is allowed to distribute verbatim copies of this 8 | license document, but modification of it is not allowed. 9 | 10 | 11 | PREAMBLE 12 | ======== 13 | 14 | The LaTeX Project Public License (LPPL) is the primary license under 15 | which the LaTeX kernel and the base LaTeX packages are distributed. 16 | 17 | You may use this license for any work of which you hold the copyright 18 | and which you wish to distribute. This license may be particularly 19 | suitable if your work is TeX-related (such as a LaTeX package), but 20 | it is written in such a way that you can use it even if your work is 21 | unrelated to TeX. 22 | 23 | The section `WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE', 24 | below, gives instructions, examples, and recommendations for authors 25 | who are considering distributing their works under this license. 26 | 27 | This license gives conditions under which a work may be distributed 28 | and modified, as well as conditions under which modified versions of 29 | that work may be distributed. 30 | 31 | We, the LaTeX3 Project, believe that the conditions below give you 32 | the freedom to make and distribute modified versions of your work 33 | that conform with whatever technical specifications you wish while 34 | maintaining the availability, integrity, and reliability of 35 | that work. If you do not see how to achieve your goal while 36 | meeting these conditions, then read the document `cfgguide.tex' 37 | and `modguide.tex' in the base LaTeX distribution for suggestions. 38 | 39 | 40 | DEFINITIONS 41 | =========== 42 | 43 | In this license document the following terms are used: 44 | 45 | `Work' 46 | Any work being distributed under this License. 47 | 48 | `Derived Work' 49 | Any work that under any applicable law is derived from the Work. 50 | 51 | `Modification' 52 | Any procedure that produces a Derived Work under any applicable 53 | law -- for example, the production of a file containing an 54 | original file associated with the Work or a significant portion of 55 | such a file, either verbatim or with modifications and/or 56 | translated into another language. 57 | 58 | `Modify' 59 | To apply any procedure that produces a Derived Work under any 60 | applicable law. 61 | 62 | `Distribution' 63 | Making copies of the Work available from one person to another, in 64 | whole or in part. Distribution includes (but is not limited to) 65 | making any electronic components of the Work accessible by 66 | file transfer protocols such as FTP or HTTP or by shared file 67 | systems such as Sun's Network File System (NFS). 68 | 69 | `Compiled Work' 70 | A version of the Work that has been processed into a form where it 71 | is directly usable on a computer system. This processing may 72 | include using installation facilities provided by the Work, 73 | transformations of the Work, copying of components of the Work, or 74 | other activities. Note that modification of any installation 75 | facilities provided by the Work constitutes modification of the Work. 76 | 77 | `Current Maintainer' 78 | A person or persons nominated as such within the Work. If there is 79 | no such explicit nomination then it is the `Copyright Holder' under 80 | any applicable law. 81 | 82 | `Base Interpreter' 83 | A program or process that is normally needed for running or 84 | interpreting a part or the whole of the Work. 85 | 86 | A Base Interpreter may depend on external components but these 87 | are not considered part of the Base Interpreter provided that each 88 | external component clearly identifies itself whenever it is used 89 | interactively. Unless explicitly specified when applying the 90 | license to the Work, the only applicable Base Interpreter is a 91 | `LaTeX-Format' or in the case of files belonging to the 92 | `LaTeX-format' a program implementing the `TeX language'. 93 | 94 | 95 | 96 | CONDITIONS ON DISTRIBUTION AND MODIFICATION 97 | =========================================== 98 | 99 | 1. Activities other than distribution and/or modification of the Work 100 | are not covered by this license; they are outside its scope. In 101 | particular, the act of running the Work is not restricted and no 102 | requirements are made concerning any offers of support for the Work. 103 | 104 | 2. You may distribute a complete, unmodified copy of the Work as you 105 | received it. Distribution of only part of the Work is considered 106 | modification of the Work, and no right to distribute such a Derived 107 | Work may be assumed under the terms of this clause. 108 | 109 | 3. You may distribute a Compiled Work that has been generated from a 110 | complete, unmodified copy of the Work as distributed under Clause 2 111 | above, as long as that Compiled Work is distributed in such a way that 112 | the recipients may install the Compiled Work on their system exactly 113 | as it would have been installed if they generated a Compiled Work 114 | directly from the Work. 115 | 116 | 4. If you are the Current Maintainer of the Work, you may, without 117 | restriction, modify the Work, thus creating a Derived Work. You may 118 | also distribute the Derived Work without restriction, including 119 | Compiled Works generated from the Derived Work. Derived Works 120 | distributed in this manner by the Current Maintainer are considered to 121 | be updated versions of the Work. 122 | 123 | 5. If you are not the Current Maintainer of the Work, you may modify 124 | your copy of the Work, thus creating a Derived Work based on the Work, 125 | and compile this Derived Work, thus creating a Compiled Work based on 126 | the Derived Work. 127 | 128 | 6. If you are not the Current Maintainer of the Work, you may 129 | distribute a Derived Work provided the following conditions are met 130 | for every component of the Work unless that component clearly states 131 | in the copyright notice that it is exempt from that condition. Only 132 | the Current Maintainer is allowed to add such statements of exemption 133 | to a component of the Work. 134 | 135 | a. If a component of this Derived Work can be a direct replacement 136 | for a component of the Work when that component is used with the 137 | Base Interpreter, then, wherever this component of the Work 138 | identifies itself to the user when used interactively with that 139 | Base Interpreter, the replacement component of this Derived Work 140 | clearly and unambiguously identifies itself as a modified version 141 | of this component to the user when used interactively with that 142 | Base Interpreter. 143 | 144 | b. Every component of the Derived Work contains prominent notices 145 | detailing the nature of the changes to that component, or a 146 | prominent reference to another file that is distributed as part 147 | of the Derived Work and that contains a complete and accurate log 148 | of the changes. 149 | 150 | c. No information in the Derived Work implies that any persons, 151 | including (but not limited to) the authors of the original version 152 | of the Work, provide any support, including (but not limited to) 153 | the reporting and handling of errors, to recipients of the 154 | Derived Work unless those persons have stated explicitly that 155 | they do provide such support for the Derived Work. 156 | 157 | d. You distribute at least one of the following with the Derived Work: 158 | 159 | 1. A complete, unmodified copy of the Work; 160 | if your distribution of a modified component is made by 161 | offering access to copy the modified component from a 162 | designated place, then offering equivalent access to copy 163 | the Work from the same or some similar place meets this 164 | condition, even though third parties are not compelled to 165 | copy the Work along with the modified component; 166 | 167 | 2. Information that is sufficient to obtain a complete, 168 | unmodified copy of the Work. 169 | 170 | 7. If you are not the Current Maintainer of the Work, you may 171 | distribute a Compiled Work generated from a Derived Work, as long as 172 | the Derived Work is distributed to all recipients of the Compiled 173 | Work, and as long as the conditions of Clause 6, above, are met with 174 | regard to the Derived Work. 175 | 176 | 8. The conditions above are not intended to prohibit, and hence do not 177 | apply to, the modification, by any method, of any component so that it 178 | becomes identical to an updated version of that component of the Work as 179 | it is distributed by the Current Maintainer under Clause 4, above. 180 | 181 | 9. Distribution of the Work or any Derived Work in an alternative 182 | format, where the Work or that Derived Work (in whole or in part) is 183 | then produced by applying some process to that format, does not relax or 184 | nullify any sections of this license as they pertain to the results of 185 | applying that process. 186 | 187 | 10. a. A Derived Work may be distributed under a different license 188 | provided that license itself honors the conditions listed in 189 | Clause 6 above, in regard to the Work, though it does not have 190 | to honor the rest of the conditions in this license. 191 | 192 | b. If a Derived Work is distributed under a different license, that 193 | Derived Work must provide sufficient documentation as part of 194 | itself to allow each recipient of that Derived Work to honor the 195 | restrictions in Clause 6 above, concerning changes from the Work. 196 | 197 | 11. This license places no restrictions on works that are unrelated to 198 | the Work, nor does this license place any restrictions on aggregating 199 | such works with the Work by any means. 200 | 201 | 12. Nothing in this license is intended to, or may be used to, prevent 202 | complete compliance by all parties with all applicable laws. 203 | 204 | 205 | NO WARRANTY 206 | =========== 207 | 208 | There is no warranty for the Work. Except when otherwise stated in 209 | writing, the Copyright Holder provides the Work `as is', without 210 | warranty of any kind, either expressed or implied, including, but not 211 | limited to, the implied warranties of merchantability and fitness for a 212 | particular purpose. The entire risk as to the quality and performance 213 | of the Work is with you. Should the Work prove defective, you assume 214 | the cost of all necessary servicing, repair, or correction. 215 | 216 | In no event unless required by applicable law or agreed to in writing 217 | will The Copyright Holder, or any author named in the components of the 218 | Work, or any other party who may distribute and/or modify the Work as 219 | permitted above, be liable to you for damages, including any general, 220 | special, incidental or consequential damages arising out of any use of 221 | the Work or out of inability to use the Work (including, but not limited 222 | to, loss of data, data being rendered inaccurate, or losses sustained by 223 | anyone as a result of any failure of the Work to operate with any other 224 | programs), even if the Copyright Holder or said author or said other 225 | party has been advised of the possibility of such damages. 226 | 227 | 228 | MAINTENANCE OF THE WORK 229 | ======================= 230 | 231 | The Work has the status `author-maintained' if the Copyright Holder 232 | explicitly and prominently states near the primary copyright notice in 233 | the Work that the Work can only be maintained by the Copyright Holder 234 | or simply that it is `author-maintained'. 235 | 236 | The Work has the status `maintained' if there is a Current Maintainer 237 | who has indicated in the Work that they are willing to receive error 238 | reports for the Work (for example, by supplying a valid e-mail 239 | address). It is not required for the Current Maintainer to acknowledge 240 | or act upon these error reports. 241 | 242 | The Work changes from status `maintained' to `unmaintained' if there 243 | is no Current Maintainer, or the person stated to be Current 244 | Maintainer of the work cannot be reached through the indicated means 245 | of communication for a period of six months, and there are no other 246 | significant signs of active maintenance. 247 | 248 | You can become the Current Maintainer of the Work by agreement with 249 | any existing Current Maintainer to take over this role. 250 | 251 | If the Work is unmaintained, you can become the Current Maintainer of 252 | the Work through the following steps: 253 | 254 | 1. Make a reasonable attempt to trace the Current Maintainer (and 255 | the Copyright Holder, if the two differ) through the means of 256 | an Internet or similar search. 257 | 258 | 2. If this search is successful, then enquire whether the Work 259 | is still maintained. 260 | 261 | a. If it is being maintained, then ask the Current Maintainer 262 | to update their communication data within one month. 263 | 264 | b. If the search is unsuccessful or no action to resume active 265 | maintenance is taken by the Current Maintainer, then announce 266 | within the pertinent community your intention to take over 267 | maintenance. (If the Work is a LaTeX work, this could be 268 | done, for example, by posting to comp.text.tex.) 269 | 270 | 3a. If the Current Maintainer is reachable and agrees to pass 271 | maintenance of the Work to you, then this takes effect 272 | immediately upon announcement. 273 | 274 | b. If the Current Maintainer is not reachable and the Copyright 275 | Holder agrees that maintenance of the Work be passed to you, 276 | then this takes effect immediately upon announcement. 277 | 278 | 4. If you make an `intention announcement' as described in 2b. above 279 | and after three months your intention is challenged neither by 280 | the Current Maintainer nor by the Copyright Holder nor by other 281 | people, then you may arrange for the Work to be changed so as 282 | to name you as the (new) Current Maintainer. 283 | 284 | 5. If the previously unreachable Current Maintainer becomes 285 | reachable once more within three months of a change completed 286 | under the terms of 3b) or 4), then that Current Maintainer must 287 | become or remain the Current Maintainer upon request provided 288 | they then update their communication data within one month. 289 | 290 | A change in the Current Maintainer does not, of itself, alter the fact 291 | that the Work is distributed under the LPPL license. 292 | 293 | If you become the Current Maintainer of the Work, you should 294 | immediately provide, within the Work, a prominent and unambiguous 295 | statement of your status as Current Maintainer. You should also 296 | announce your new status to the same pertinent community as 297 | in 2b) above. 298 | 299 | 300 | WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE 301 | ====================================================== 302 | 303 | This section contains important instructions, examples, and 304 | recommendations for authors who are considering distributing their 305 | works under this license. These authors are addressed as `you' in 306 | this section. 307 | 308 | Choosing This License or Another License 309 | ---------------------------------------- 310 | 311 | If for any part of your work you want or need to use *distribution* 312 | conditions that differ significantly from those in this license, then 313 | do not refer to this license anywhere in your work but, instead, 314 | distribute your work under a different license. You may use the text 315 | of this license as a model for your own license, but your license 316 | should not refer to the LPPL or otherwise give the impression that 317 | your work is distributed under the LPPL. 318 | 319 | The document `modguide.tex' in the base LaTeX distribution explains 320 | the motivation behind the conditions of this license. It explains, 321 | for example, why distributing LaTeX under the GNU General Public 322 | License (GPL) was considered inappropriate. Even if your work is 323 | unrelated to LaTeX, the discussion in `modguide.tex' may still be 324 | relevant, and authors intending to distribute their works under any 325 | license are encouraged to read it. 326 | 327 | A Recommendation on Modification Without Distribution 328 | ----------------------------------------------------- 329 | 330 | It is wise never to modify a component of the Work, even for your own 331 | personal use, without also meeting the above conditions for 332 | distributing the modified component. While you might intend that such 333 | modifications will never be distributed, often this will happen by 334 | accident -- you may forget that you have modified that component; or 335 | it may not occur to you when allowing others to access the modified 336 | version that you are thus distributing it and violating the conditions 337 | of this license in ways that could have legal implications and, worse, 338 | cause problems for the community. It is therefore usually in your 339 | best interest to keep your copy of the Work identical with the public 340 | one. Many works provide ways to control the behavior of that work 341 | without altering any of its licensed components. 342 | 343 | How to Use This License 344 | ----------------------- 345 | 346 | To use this license, place in each of the components of your work both 347 | an explicit copyright notice including your name and the year the work 348 | was authored and/or last substantially modified. Include also a 349 | statement that the distribution and/or modification of that 350 | component is constrained by the conditions in this license. 351 | 352 | Here is an example of such a notice and statement: 353 | 354 | %% pig.dtx 355 | %% Copyright 2005 M. Y. Name 356 | % 357 | % This work may be distributed and/or modified under the 358 | % conditions of the LaTeX Project Public License, either version 1.3 359 | % of this license or (at your option) any later version. 360 | % The latest version of this license is in 361 | % http://www.latex-project.org/lppl.txt 362 | % and version 1.3 or later is part of all distributions of LaTeX 363 | % version 2005/12/01 or later. 364 | % 365 | % This work has the LPPL maintenance status `maintained'. 366 | % 367 | % The Current Maintainer of this work is M. Y. Name. 368 | % 369 | % This work consists of the files pig.dtx and pig.ins 370 | % and the derived file pig.sty. 371 | 372 | Given such a notice and statement in a file, the conditions 373 | given in this license document would apply, with the `Work' referring 374 | to the three files `pig.dtx', `pig.ins', and `pig.sty' (the last being 375 | generated from `pig.dtx' using `pig.ins'), the `Base Interpreter' 376 | referring to any `LaTeX-Format', and both `Copyright Holder' and 377 | `Current Maintainer' referring to the person `M. Y. Name'. 378 | 379 | If you do not want the Maintenance section of LPPL to apply to your 380 | Work, change `maintained' above into `author-maintained'. 381 | However, we recommend that you use `maintained', as the Maintenance 382 | section was added in order to ensure that your Work remains useful to 383 | the community even when you can no longer maintain and support it 384 | yourself. 385 | 386 | Derived Works That Are Not Replacements 387 | --------------------------------------- 388 | 389 | Several clauses of the LPPL specify means to provide reliability and 390 | stability for the user community. They therefore concern themselves 391 | with the case that a Derived Work is intended to be used as a 392 | (compatible or incompatible) replacement of the original Work. If 393 | this is not the case (e.g., if a few lines of code are reused for a 394 | completely different task), then clauses 6b and 6d shall not apply. 395 | 396 | 397 | Important Recommendations 398 | ------------------------- 399 | 400 | Defining What Constitutes the Work 401 | 402 | The LPPL requires that distributions of the Work contain all the 403 | files of the Work. It is therefore important that you provide a 404 | way for the licensee to determine which files constitute the Work. 405 | This could, for example, be achieved by explicitly listing all the 406 | files of the Work near the copyright notice of each file or by 407 | using a line such as: 408 | 409 | % This work consists of all files listed in manifest.txt. 410 | 411 | in that place. In the absence of an unequivocal list it might be 412 | impossible for the licensee to determine what is considered by you 413 | to comprise the Work and, in such a case, the licensee would be 414 | entitled to make reasonable conjectures as to which files comprise 415 | the Work. 416 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![CTAN Version](https://img.shields.io/ctan/v/install-latex-guide-zh-cn)](https://ctan.org/pkg/install-latex-guide-zh-cn) 2 | [![GitHub Release](https://img.shields.io/github/v/release/OsbertWang/install-latex-guide-zh-cn)](https://github.com/OsbertWang/install-latex-guide-zh-cn/releases/latest) 3 | [![Actions Status](https://github.com/OsbertWang/install-latex-guide-zh-cn/workflows/Automated%20testing/badge.svg)](https://github.com/OsbertWang/install-latex-guide-zh-cn/actions) 4 | [![GitHub Repo stars](https://img.shields.io/github/stars/OsbertWang/install-latex-guide-zh-cn)](https://github.com/OsbertWang/install-latex-guide-zh-cn) 5 | [![GitHub Last Commit](https://img.shields.io/github/last-commit/OsbertWang/install-latex-guide-zh-cn)](https://github.com/OsbertWang/install-latex-guide-zh-cn/commits) 6 | # Install-LaTeX-Guide-zh-cn (A short introduction to LaTeX installation written in Chinese) 7 | 8 | This package will introduce the operations related to installing TeX Live (introducing MacTeX in macOS), upgrading packages, and compiling simple documents on Windows 11, Ubuntu 24.04, and macOS systems, and mainly introducing command line operations. 9 | At the same time, it briefly introduces the use of several common editors under different operating systems, and additionally adds some related content using Online LaTeX editor, e.g. [Overleaf](https://www.overleaf.com). 10 | 11 | Users are advised to read [texlive-zh-cn](https://www.tug.org/texlive/doc/texlive-zh-cn/texlive-zh-cn.pdf) and [lshort-zh-cn](http://mirrors.ctan.org/info/lshort/chinese/lshort-zh-cn.pdf) for a more comprehensive understanding of the basic content. 12 | 13 | The code involved in this article also asks users to do more, don't simply copy and paste. 14 | 15 | If you need to compile the source files, please make sure to install the fandol font and use the `xelatex` command. 16 | TeX Live users are recommended to use the following commands 17 | ``` 18 | latexmk -xelatex -synctex=1 install-latex-guide-zh-cn 19 | ``` 20 | Users who cannot use `latexmk` can execute `make.bat` or `make` according to their operating system. `build.lua` is also provided so that users can execute `l3build doc` or `l3build ctan` to compile the source files. 21 | 22 | If you need the PDF file compiled by this project, you can download it from [Releases](https://github.com/OsbertWang/install-latex-zh-cn/releases/latest). 23 | 24 | # License 25 | 26 | This work is released under the LaTeX Project Public License, v1.3c or later. 27 | 28 | # 一份简短的关于 LaTeX 安装的介绍 29 | 30 | 本文将介绍 Windows 11、Ubuntu 24.04 和 macOS 系统中安装 TeX Live (macOS 中介绍 MacTeX)、升级宏包、编译简易文档的相关操作, 并多以介绍命令行操作为主. 31 | 同时简要介绍不同操作系统下几款常见编辑器的使用方法, 并额外补充了一些使用在线 LaTeX 编辑器, 如 [Overleaf](https://www.overleaf.com), 的相关内容. 32 | 33 | 建议用户阅读 [texlive-zh-cn](https://www.tug.org/texlive/doc/texlive-zh-cn/texlive-zh-cn.pdf) 和 [lshort-zh-cn](http://mirrors.ctan.org/info/lshort/chinese/lshort-zh-cn.pdf) 以更全面地了解基础内容. 34 | 35 | 本文所涉及到的代码还请用户多多动手, 不要简单地复制粘贴. 36 | 37 | 若需要编译源文件, 请确保安装 fandol 字体, 并使用 `xelatex` 命令. 38 | 推荐 TeX Live 用户使用如下命令 39 | ``` 40 | latexmk -xelatex -synctex=1 install-latex-guide-zh-cn 41 | ``` 42 | 无法使用 `latexmk` 的用户可以根据自己的操作系统执行 `make.bat` 或 `make`. 本项目同时提供了 `build.lua`, 用户可执行 `l3build doc` 或 `l3build ctan` 来编译源文件. 43 | 44 | 若需要本项目编译完成的 PDF 文件, 可至 [Releases](https://github.com/OsbertWang/install-latex-zh-cn/releases/latest) 处下载. 45 | 46 | # 开源协议 47 | 48 | 本次工作将遵循协议 LaTeX Project Public License, v1.3c 或其后版本. 49 | -------------------------------------------------------------------------------- /build.lua: -------------------------------------------------------------------------------- 1 | --[==========================================[-- 2 | L3BUILD FILE FOR INSTALL-LATEX-GUIDE-ZH-CN 3 | Check PDF File & Directory After Build 4 | --]==========================================]-- 5 | 6 | --[==========================================[-- 7 | Basic Information 8 | Do Check Before Upload 9 | --]==========================================]-- 10 | module = "install-latex-guide-zh-cn" 11 | version = "2025.6.1" 12 | maintainer = "Ran Wang" 13 | uploader = maintainer 14 | maintainid = "OsbertWang" 15 | email = "ranwang.osbert@outlook.com" 16 | repository = "https://github.com/" .. maintainid .. "/" .. module 17 | announcement = "" 18 | note = "The document now introduces Ubuntu 24.04 instead of 22.04. Please sync the homepage of this package accordingly." 19 | summary = "A short introduction to LaTeX installation written in Chinese" 20 | description = [[ 21 | This package will introduce the operations related to installing TeX Live (introducing MacTeX in macOS), upgrading packages, and compiling simple documents on Windows 11, Ubuntu 24.04, and macOS systems, and mainly introducing command line operations. 22 | ]] 23 | 24 | --[==========================================[-- 25 | Build, Pack and Upload To CTAN 26 | Do not Modify Unless Necessary 27 | --]==========================================]-- 28 | ctanzip = module 29 | excludefiles = {"*~"} 30 | supportdir = "chapter" 31 | textfiles = {"*.md", "LICENSE", "*.lua", "makefile", "*.bat"} 32 | typesetexe = "latexmk" 33 | typesetfiles = {module .. ".tex"} 34 | typesetopts = "-xelatex -synctex=1 -interaction=nonstopmode" 35 | typesetsuppfiles = {"*.tex"} 36 | 37 | uploadconfig = { 38 | pkg = module, 39 | version = version, 40 | author = maintainer, 41 | uploader = uploader, 42 | email = email, 43 | summary = summary, 44 | description = description, 45 | announcement = announcement, 46 | note = note, 47 | license = "lppl1.3c", 48 | ctanPath = "/info/" .. module, 49 | home = repository, 50 | support = repository .. "/issues", 51 | bugtracker = repository .. "/issues", 52 | repository = repository, 53 | development = "https://github.com/" .. maintainid, 54 | update = true 55 | } 56 | 57 | function docinit_hook() 58 | local docsuppdir = typesetdir .. "/" .. supportdir 59 | mkdir(docsuppdir) 60 | for _,supp in pairs(typesetsuppfiles) do 61 | cp(supp, supportdir, docsuppdir) 62 | rm(typesetdir, supp) 63 | end 64 | cp(module .. ".tex", currentdir, typesetdir) 65 | return 0 66 | end 67 | function tex(file,dir,cmd) 68 | dir = dir or "." 69 | cmd = cmd or typesetexe .. " " .. typesetopts 70 | return run(dir, cmd .. file) 71 | end 72 | function copyctan() 73 | local pkgdir = ctandir .. "/" .. ctanpkg 74 | mkdir(pkgdir) 75 | for _,main in ipairs({typesetsuppfiles, pdffiles}) do 76 | for _,glob in pairs(main) do 77 | cp(glob, typesetdir, pkgdir) 78 | end 79 | end 80 | local pkgsuppdir = ctandir .. "/" .. ctanpkg .. "/" .. supportdir 81 | mkdir(pkgsuppdir) 82 | for _,supptab in pairs(typesetsuppfiles) do 83 | cp(supptab, supportdir, pkgsuppdir) 84 | end 85 | end -------------------------------------------------------------------------------- /chapter/addition.tex: -------------------------------------------------------------------------------- 1 | % !TeX root = ../install-latex-guide-zh-cn.tex 2 | 3 | \chapter{有关 Ubuntu 和 WSL 的补充}\label{chp:appendix:addition} 4 | 5 | \section{更换 Ubuntu 24.04 源}\label{sec:addition:source} 6 | 7 | 鉴于大陆网络现状, 8 | 建议更换 Ubuntu 24.04 源至国内, 9 | 例如更换至清华大学. 10 | 在 \textsf{Terminal} 中执行 11 | \begin{lstlisting}[deletekeywords = apt] 12 | sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak 13 | \end{lstlisting} 14 | 备份 \texttt{sources.list} 文件. 15 | 接下来执行 16 | \begin{lstlisting}[deletekeywords = apt] 17 | sudo gedit /etc/apt/sources.list 18 | \end{lstlisting} 19 | 将文件替换为以下内容% 20 | \footnote{本段文字可至% 21 | \href{https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/}{清华大学镜像网站}% 22 | 获取} 23 | \begin{lstlisting}[ 24 | morekeywords = {deb, noble, noble-updates, noble-backports, noble-security}, 25 | alsoletter = -] 26 | # 默认注释了源码镜像以提高 apt update 速度, 如有需要可自行取消注释 27 | deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble main restricted universe multiverse 28 | # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble main restricted universe multiverse 29 | deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-updates main restricted universe multiverse 30 | # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-updates main restricted universe multiverse 31 | deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-backports main restricted universe multiverse 32 | # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-backports main restricted universe multiverse 33 | 34 | # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-security main restricted universe multiverse 35 | # # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-security main restricted universe multiverse 36 | 37 | deb http://security.ubuntu.com/ubuntu/ noble-security main restricted universe multiverse 38 | # deb-src http://security.ubuntu.com/ubuntu/ noble-security main restricted universe multiverse 39 | 40 | # 预发布软件源, 不建议启用 41 | # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-proposed main restricted universe multiverse 42 | # # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-proposed main restricted universe multiverse 43 | \end{lstlisting} 44 | 保存退出. 45 | 再执行 46 | \begin{lstlisting} 47 | sudo apt update && sudo apt upgrade 48 | \end{lstlisting} 49 | 换源并更新. 50 | 若更改错误, 51 | 可执行 52 | \begin{lstlisting}[deletekeywords = apt] 53 | sudo cp /etc/apt/sources.list.bak /etc/apt/sources.list 54 | \end{lstlisting} 55 | 恢复文件. 56 | 57 | \section{安装字体}\label{sec:addition:font} 58 | 59 | 有用户指出, 60 | Ubuntu 中安装字体比较麻烦. 61 | 这里给出一个方法. 62 | 63 | 在安装字体前先保证 "fontconfig" 和 "xfonts-utils" 已安装 64 | \begin{lstlisting} 65 | sudo apt install fontconfig xfonts-utils 66 | \end{lstlisting} 67 | 获取需要安装的字体文件, 68 | 假设文件保存在 \path{~/myfonts/}, 69 | WSL 用户甚至可以保存在主系统路径中. 70 | 然后将其链接到 \path{/usr/share/fonts/} 文件夹 71 | \begin{lstlisting} 72 | sudo ln -s ~/myfonts /usr/share/fonts 73 | \end{lstlisting} 74 | 最后建立字体缓存 75 | \begin{lstlisting} 76 | mkfontscale 77 | mkfontdir 78 | fc-cache -fv 79 | \end{lstlisting} 80 | 这时执行 81 | \begin{lstlisting} 82 | fc-list 83 | \end{lstlisting} 84 | 即可见到目前可用的字体. 85 | 若要删除刚刚安装的字体, 86 | 只需要直接删除 87 | \begin{lstlisting} 88 | sudo rm /usr/share/fonts/myfonts 89 | \end{lstlisting} 90 | 91 | 实际上有部分字体可直接使用源进行安装, 92 | 如安装字体 Noto CJK 93 | \begin{lstlisting} 94 | sudo apt install fonts-noto-cjk 95 | sudo apt install fonts-noto-cjk-extra 96 | \end{lstlisting} 97 | 安装 Windows 系统中常见的字体 Andale Mono, 98 | Arial Black, 99 | Arial (Bold, Italic, Bold Italic), 100 | Comic Sans MS (Bold), 101 | Courier New (Bold, Italic, Bold Italic), 102 | Georgia (Bold, Italic, Bold Italic), 103 | Impact, 104 | Times New Roman (Bold, Italic, Bold Italic), 105 | Trebuchet (Bold, Italic, Bold Italic), 106 | Verdana (Bold, Italic, Bold Italic), 107 | Webdings 108 | \begin{lstlisting} 109 | sudo apt install ttf-mscorefonts-installer 110 | \end{lstlisting} 111 | 安装字体文泉驿正黑, 112 | 文泉驿微米黑, 113 | 文泉驿等宽微米黑, 114 | 文泉驿点阵宋体, 115 | 文泉驿点阵楷体 116 | \begin{lstlisting} 117 | sudo apt install ttf-wqy-zenhei 118 | \end{lstlisting} 119 | 120 | \section{反向代理 PPA}\label{sec:addition:proxy} 121 | 122 | 这里介绍中科大的\href{https://mirrors.ustc.edu.cn/}{反向代理}, 123 | 将 124 | \begin{lstlisting}[deletekeywords = apt] 125 | /etc/apt/sources.list.d/ 126 | \end{lstlisting} 127 | 中文件的内容 128 | \begin{lstlisting} 129 | http(s)://ppa.launchpad.net 130 | \end{lstlisting} 131 | 改为 132 | \begin{lstlisting} 133 | https://launchpad.proxy.ustclug.org 134 | \end{lstlisting} 135 | 而后再 136 | \begin{lstlisting} 137 | sudo apt update 138 | \end{lstlisting} 139 | 即完成换源. 140 | 有时地址太多而逐个换太麻烦, 141 | 可以直接使用如下命令直接替换% 142 | \footnote{参见 \url{https://mogeko.me/zh-cn/posts/zh-cn/035/}} 143 | \begin{lstlisting}[deletekeywords = apt] 144 | sudo find /etc/apt/sources.list.d/ -type f -name "*.list" -exec sed -i.bak -r 's#deb(-src)?\s*http(s)?://ppa.launchpad.net#deb\1 https\2://launchpad.proxy.ustclug.org#ig' {} \; 145 | \end{lstlisting} 146 | 147 | \section{用 VS Code 作为 WSL 中的编辑器}\label{sec:addition:wsl-editor} 148 | 149 | 微软最近频繁推荐 WSL 作为开发工具, 150 | 详情阅读% 151 | \href{https://learn.microsoft.com/zh-cn/windows/wsl/tutorials/wsl-vscode}{微软文档}. 152 | 本手册在此基础上, 153 | 借助 \href{https://code.visualstudio.com/download}{VS Code} 的 \href{https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack}{Remote Development} 154 | 插件实现若干功能. 155 | 若非特别指明, 156 | 以下操作均在 WSL 中用 \textsf{bash} 执行. 157 | 158 | VS Code 的插件权限有限, 159 | 当更改 \texttt{sources.list} 时, 160 | 先在 \textsf{bash} 中将 \texttt{sources.list} 备份 161 | \begin{lstlisting}[deletekeywords = apt] 162 | sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak 163 | \end{lstlisting} 164 | 再用 VS Code 打开文档 165 | \begin{lstlisting}[deletekeywords = apt, morekeywords = code] 166 | code /etc/apt/sources.list 167 | \end{lstlisting} 168 | 并对其中内容进行更改, 169 | 并且另存为 170 | \begin{lstlisting} 171 | ~/sources.list.sav 172 | \end{lstlisting} 173 | 执行 174 | \begin{lstlisting}[deletekeywords = apt] 175 | sudo cp ~/sources.list.sav /etc/apt/sources.list 176 | \end{lstlisting} 177 | 替换文档. 178 | 若发现文档有错误, 179 | 执行 180 | \begin{lstlisting}[deletekeywords = apt] 181 | sudo cp /etc/apt/sources.list.bak /etc/apt/sources.list 182 | \end{lstlisting} 183 | 恢复文档. 184 | 185 | 更改 \texttt{.bashrc} 相对简单, 186 | 将 \texttt{.bashrc} 备份 187 | \begin{lstlisting} 188 | cp ~/.bashrc ~/.bashrc.bak 189 | \end{lstlisting} 190 | 用 VS Code 打开文档 191 | \begin{lstlisting}[morekeywords = code] 192 | code ~/.bashrc 193 | \end{lstlisting} 194 | 并对其中内容进行更改并保存. 195 | 若更改错误, 196 | 可以执行 197 | \begin{lstlisting} 198 | cp ~/.bashrc.bak ~/.bashrc 199 | \end{lstlisting} 200 | 恢复文档. 201 | 202 | 利用 203 | \href{https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop}{\LaTeX\ Workshop} 204 | 插件可以将 VS Code 作为 \LaTeX\ 编辑器, 205 | 难点在于如何设置. 206 | 这里还是建议用户阅读插件 207 | \href{https://github.com/James-Yu/LaTeX-Workshop/wiki}{Wiki} 208 | 了解更多内容. 209 | 以下 VS Code 设置的 \texttt{json} 文件内容为个人自用的 \LaTeX\ Workshop 设置, 210 | 仅供参考, 211 | 其中注释的部分是调用外部 SumatraPDF 阅读器的设置, 212 | 用户可阅读 213 | \href{https://github.com/OsbertWang/latex-editor-sumatrapdf}{\textsf{latex-editor-sumatrapdf}} 214 | 来了解更多内容. 215 | \begin{lstlisting}[language = json] 216 | "latex-workshop.latex.tools": [ 217 | { 218 | "name": "latexmkpdf", 219 | "command": "latexmk", 220 | "args": 221 | [ 222 | "-synctex=1", "%DOCFILE%", 223 | "-halt-on-error", "-file-line-error", 224 | "-pdf", "-interaction=nonstopmode" 225 | ] 226 | }, 227 | { 228 | "name": "latexmkxe", 229 | "command": "latexmk", 230 | "args": 231 | [ 232 | "-synctex=1", "%DOCFILE%", 233 | "-halt-on-error", "-file-line-error", 234 | "-xelatex", "-interaction=nonstopmode", 235 | ] 236 | }, 237 | ], 238 | "latex-workshop.latex.recipes": [ 239 | { 240 | "name": "latexmkpdf", 241 | "tools": [ "latexmkpdf" ] 242 | }, 243 | { 244 | "name": "latexmkxe", 245 | "tools": [ "latexmkxe" ] 246 | } 247 | ], 248 | "latex-workshop.latex.autoBuild.run": "never", 249 | "latex-workshop.view.pdf.viewer": "tab" 250 | // "latex-workshop.view.pdf.viewer": "external", 251 | // "latex-workshop.view.pdf.ref.viewer": "external", 252 | // "latex-workshop.view.pdf.external.viewer.command": "/SumatraPDF.exe", 253 | // "latex-workshop.view.pdf.external.viewer.args": [ 254 | // "-inverse-search", "%PDF%", 255 | // "\"/bin/code.cmd\" -r -g \"%f:%l\"", 256 | // ], 257 | // "latex-workshop.view.pdf.external.synctex.command":"/SumatraPDF.exe", 258 | // "latex-workshop.view.pdf.external.synctex.args":[ 259 | // "-forward-search", "%TEX%", "%LINE%", "%PDF%" 260 | // ], 261 | \end{lstlisting} 262 | 263 | 实际使用时, 264 | 用户需要结合自身安装情况更换 \path{} 和 \path{}, 265 | 即 SumatraPDF 和 VS Code 各自的安装路径. 266 | 267 | 另外需要声明的是, 268 | \LaTeX\ Workshop 插件并不局限在 WSL 当中, 269 | 它的配置是可以通用的. 270 | 271 | \section{迁移 WSL 的安装位置} 272 | 273 | 考虑到一部分用户的系统盘空间有限, 274 | 且根据% 275 | \href{https://learn.microsoft.com/zh-cn/windows/wsl/troubleshooting?source=recommendations#installation-issues}{微软官方文档}, 276 | WSL 只能安装在系统盘, 277 | 因此可以考虑迁移 WSL 的安装位置到其他盘. 278 | 本部分内容源自 279 | \href{https://superuser.com/questions/1701175/installing-ubuntu-on-mnt-d-with-wsl}{\textsf{Stack\textbf{Exchange}}}. 280 | 方法牵扯到主系统和子系统的操作. 281 | 282 | 第一步, 283 | 建立新的位置. 284 | 假设新位置在 \path{X:\} 盘. 285 | 在 \textsf{cmd} 中执行 286 | \begin{lstlisting} 287 | wsl -l 288 | \end{lstlisting} 289 | 可以查到当前已经安装的 WSL 分发, 290 | 例如 291 | \begin{lstlisting} 292 | 适用于 Linux 的 Windows 子系统分发: 293 | Ubuntu (默认) 294 | \end{lstlisting} 295 | 在 \textsf{bash} 中执行 296 | \begin{lstlisting} 297 | lsb_release -a 298 | \end{lstlisting} 299 | 查到实际 WSL 内 Ubuntu 的版本, 300 | 例如 301 | \begin{lstlisting}[language = {}] 302 | No LSB modules are available. 303 | Distributor ID: Ubuntu 304 | Description: Ubuntu 24.04.2 LTS 305 | Release: 24.04 306 | Codename: noble 307 | \end{lstlisting} 308 | 然后在 \textsf{cmd} 中执行 309 | \begin{lstlisting} 310 | mkdir X:\WSL\instances\ubuntu2404 311 | mkdir X:\WSL\images 312 | cd X:\WSL\images 313 | \end{lstlisting} 314 | %\begin{lstlisting} 315 | % New-Item -ItemType Directory -Path "X:\WSL\instances\Ubuntu2204" -Force 316 | % Set-Location (New-Item -ItemType Directory -Path "X:\WSL\images" -Force) 317 | %\end{lstlisting} 318 | 创建新的位置. 319 | 这里起名 \texttt{ubuntu2404} 是因为 Ubuntu 实际版本为 24.04, 320 | 也可以起其他名字. 321 | 322 | 第二步, 323 | 导出原 WSL 分发并导入新位置. 324 | 在 \textsf{cmd} 中执行 325 | \begin{lstlisting} 326 | wsl --export Ubuntu ubuntu.tar 327 | wsl --import ubuntu2404 X:\WSL\instances\ubuntu2404 ubuntu.tar --version 2 328 | \end{lstlisting} 329 | 第一行的 \texttt{Ubuntu} 指的是系统默认的 WSL 分发, 330 | 这条命令将原本的分发导出为一个压缩包. 331 | 第二行的 \texttt{ubuntu2404} 是未来指定的 WSL 分发, 332 | 也就是将前面导出的压缩包导入成新的 WSL 分发. 333 | 334 | 第三步, 335 | 启动新的分发并且设置为默认. 336 | 在 \textsf{cmd} 中执行 337 | \begin{lstlisting} 338 | wsl ~ -d ubuntu2404 339 | \end{lstlisting} 340 | 进入 \texttt{ubuntu2404} 分发的 WSL 系统, 341 | 在当前 \textsf{bash} 中执行 342 | \begin{lstlisting}[deletekeywords = wsl] 343 | sudo -e /etc/wsl.conf 344 | \end{lstlisting} 345 | 输入以下内容 346 | \begin{lstlisting} 347 | [user] 348 | default= 349 | \end{lstlisting} 350 | "" 是用户自定义的 WSL 的用户名, 351 | 个人用了原本 \texttt{Ubuntu} 分发内的用户名. 352 | 然后依次 \keys{\ctrl + X}, \keys{Y}, \keys{\enter} 保存退出. 353 | 退出 \textsf{bash}, 354 | 在 \textsf{cmd} 中执行 355 | \begin{lstlisting} 356 | wsl --terminate ubuntu2404 357 | wsl ~ -d ubuntu2404 358 | \end{lstlisting} 359 | 这时如果一切正常, 360 | 就可以将 \texttt{ubuntu2404} 设置为默认 WSL 分发, 361 | 即在 \textsf{cmd} 中执行 362 | \begin{lstlisting} 363 | wsl --set-default ubuntu2404 364 | \end{lstlisting} 365 | 这时在 \textsf{bash} 中执行 366 | \begin{lstlisting} 367 | echo $WSL_DISTRO_NAME 368 | \end{lstlisting} 369 | 返回结果 370 | \begin{lstlisting} 371 | ubuntu2404 372 | \end{lstlisting} 373 | 就表明一切正常. 374 | 375 | 第四步, 376 | 删除旧分发. 377 | 在 \textsf{cmd} 中执行 378 | \begin{lstlisting} 379 | wsl --unregister Ubuntu 380 | \end{lstlisting} 381 | 就将旧分发 \texttt{Ubuntu} 删除了. 382 | 这时在 \textsf{cmd} 中执行 383 | \begin{lstlisting} 384 | wsl -l 385 | \end{lstlisting} 386 | 将看到 387 | \begin{lstlisting} 388 | 适用于 Linux 的 Windows 子系统分发: 389 | ubuntu2404 (默认) 390 | \end{lstlisting} 391 | 392 | 实际上, 393 | 将整个 WSL 的安装位置迁移还有一个好处. 394 | 根据% 395 | \href{https://learn.microsoft.com/zh-cn/windows/wsl/filesystems#file-storage-and-performance-across-file-systems}{微软官方文档}, 396 | 将项目文件直接存储在 WSL 的驱动器上, 397 | 性能速度会提高. 398 | -------------------------------------------------------------------------------- /chapter/editor.tex: -------------------------------------------------------------------------------- 1 | % !TeX root = ../install-latex-guide-zh-cn.tex 2 | 3 | \chapter{使用编辑器} 4 | 5 | \section{Windows 11 系统} 6 | 7 | 在实际操作中, 用户会发觉使用记事本编写 \texttt{tex} 文件十分不便, 8 | 因此很多用户都将其他编辑器作为自己的首选. 9 | 这里向大家介绍随 \TeX~Live 一同发行的轻量级编辑器 \TeX works 10 | 和功能更加丰富的 11 | \TeX studio. 12 | 其他编辑器无法一一介绍, 还请自己在网上寻求更多帮助. 13 | 14 | \subsection{\TeX works} 15 | 16 | \TeX works 是一款轻量级的 \LaTeX\ 编辑器, 个人认为非常适合入门级用户使用% 17 | \footnote{很多用户在编写 \texttt{tex} 文件时喜欢借助其他工具, 18 | 这不是个好习惯, 这里鼓励用户多手动敲代码}. 19 | 20 | 和大多数国产软件不同, \TeX works 不会自动在桌面生成快捷方式, 21 | 新人往往不知道如何打开它. 22 | 实际上 \TeX works 在 \TeX~Live 安装路径的 23 | \path{\bin\windows} 中, 24 | 可在 \textsf{cmd} 中执行 "texworks" 打开, 25 | 也可直接在 Windows 搜索栏里搜 \TeX works 打开. 26 | 27 | 刚开始使用 \TeX works 的用户不必过多配置, 28 | 在默认状态下打开软件、编写代码、保存文件后, 29 | 用户可使用 \TeX works 的“排版”按钮进行文档编译而不必回到命令行% 30 | \footnote{实际上编辑器的按钮也是调用命令行来编译文档, 31 | \TeX works 默认排版快捷键是 \keys{ctrl + T}}. 32 | 按钮旁边是编译命令菜单, 用户可根据需要自行选择. 33 | 34 | 下面介绍几个常用的功能. 35 | 36 | \subsubsection{显示行号} 37 | 38 | 打开 \menu{编辑 > 首选项 > 编辑器}, 选择 \menu{行号} 即可. 39 | 40 | \subsubsection{调整字体} 41 | 42 | \TeX works 有时会擅自更改编辑器所使用的字体, 43 | 很多字体``长相''诡异, 44 | 让用户误以为是乱码. 45 | 用户可在 \menu{编辑 > 首选项 > 编辑器默认配置} 46 | 和 \menu{格式 > 字体} 处进行更改. 47 | Windows 11 中字体列表见% 48 | \href{https://docs.microsoft.com/en-us/typography/fonts/windows_11_font_list}{这里}. 49 | 50 | \subsubsection{自动补全} 51 | 52 | 自动补全主要是 \keys{tab} 键的功能, 53 | 使用前需确定 \menu{首选项 > 编辑器} 中是否勾选了 \menu{启动自动补全}. 54 | 有关自动补全的更多内容用户可参考 55 | \href{https://github.com/EthanDeng/texworks-autocomplete}{\TeX works 的自动补全功能}. 56 | 57 | \subsubsection{使用模板} 58 | 59 | \TeX works支持从模板新建文档, 在 \menu{文件} 菜单中可见. 60 | 61 | \subsubsection{更改编译命令设置} 62 | 63 | \TeX works 默认提供了若干编译命令, 64 | 具体见 \menu{编辑 > 首选项 > 排版}. 65 | 实际上, 66 | 用户可以根据自己的需要, 67 | 添加、更改其中的设置. 68 | 首先明确 \TeX works 中已有一些定义, 69 | 见表~\ref{tab:editor} 70 | \footnote{参考 71 | \href{https://github.com/TeXworks/texworks/wiki/AdvancedTypesettingTools}{Advanced Typesetting Tools}}. 72 | 接下来可以定义 "latexmkpdf", 73 | 它调用 "latexmk" 并使用 "pdflatex" 等命令编译文档. 74 | 在 \menu{排版} 上点击 \menu{+}, 75 | 输入名称 "latexmkpdf" 和程序 "latexmk", 76 | 相关参数需要再次点击 \menu{+} 来予以添加, 77 | 例如添加以下这些 78 | \begin{lstlisting}[language = {}] 79 | -e 80 | $pdflatex=q/pdflatex $synctexoption %O %S/ 81 | -pdf 82 | $fullname 83 | \end{lstlisting} 84 | 这里的 "$synctexoption" 和 "$fullname" 均是 \TeX works 预定义的内容, 85 | 而其他的 "-e", "$pdflatex=..." 和 "-pdf" 需要用户自己阅读 "latexmk" 手册了解. 86 | 然后选择 \textsf{运行后查看 pdf 文件}, 87 | 再点击 \menu{OK}, 88 | 即可发现已经添加成功. 89 | 之后用户可以调用 "latexmkpdf" 来编译文档. 90 | 当然, 91 | 在 \menu{排版} 处还可以将 "latexmkpdf" 设置为默认. 92 | 93 | 类似地, 94 | 如果要定义 "latexmkxe", 95 | 可以考虑以下参数 96 | \begin{lstlisting}[language = {}] 97 | -e 98 | $xelatex=q/xelatex $synctexoption %O %S/ 99 | -xelatex 100 | $fullname 101 | \end{lstlisting} 102 | 程序依然是 "latexmk". 103 | 104 | \begin{table} 105 | \centering 106 | \caption{\TeX works 已有定义}\label{tab:variables} 107 | \begin{tabular}{>{\ttfamily}p{0.18\linewidth}p{0.75\linewidth}} 108 | \toprule 109 | Option & Description\\ 110 | \midrule 111 | "$synctexoption" & expands to ``-synctex=1'' if your tools support SyncTeX\\ 112 | "$fullname" & expands to the full name of your root document (e.g. rootfile.tex)\\ 113 | "$basename" & expands to the name (without extension) of your root document (e.g. rootfile)\\ 114 | "$suffix" & expands to the extension of your root document (e.g. tex)\\ 115 | "$directory" & expands to the absolute path to the directory containing your root document\\ 116 | \bottomrule 117 | \end{tabular} 118 | \end{table} 119 | 120 | \subsubsection{拼写检查} 121 | 122 | 默认情况, \TeX works没有搭载拼写检查字典, 需要用户自己配置. 123 | 首先, 访问 124 | \href{https://extensions.openoffice.org/dictionary}{\textsf{OpenOffice}} 125 | 下载 \texttt{.oxt} 文件. 126 | 将 \texttt{.oxt} 文件重命名为 \texttt{.zip} 文件, 127 | 解压缩得到里面的 \texttt{.dic} 和 \texttt{.aff} 文件. 128 | 接下来将它们安装到 \path{\dictionaries} 129 | \footnote{\path{} 的具体位置可以在 130 | \menu{帮助 > TeXworks 配置与资源} 中找到, 131 | 若不存在该 \path{dictionaries} 文件夹, 132 | 用户可自行建立}. 133 | 安装完成后, 在 \menu{编辑 > 拼写} 中选择即可. 134 | 135 | \subsubsection{魔法注释} 136 | 137 | 魔法注释可以直接规定主文档、文件编码和编译命令等. 138 | 例如用户写学位论文时, 往往有一个主文档和若干子文档. 139 | 在子文档的开头写上魔法注释 140 | \begin{lstlisting}[language = {[LaTeX]TeX}] 141 | % !TeX root = ../main.tex 142 | \end{lstlisting} 143 | 即可告诉系统上一级目录中的 \texttt{main.tex} 是主文档% 144 | \footnote{主文档和子文档的更多内容请参考 "\include" 和 "\input" 的用法}. 145 | \begin{lstlisting}[language = {[LaTeX]TeX}] 146 | % !TeX encoding = UTF8 147 | \end{lstlisting} 148 | 表示该文档使用 ``UTF-8'' 编码\footnote{目前建议用户多用 ``UTF-8'' 编码, 尤其是中文文档}. 149 | \begin{lstlisting}[language = {[LaTeX]TeX}] 150 | % !TeX program = xelatex 151 | \end{lstlisting} 152 | 表示该文档使用 "xelatex" 编译命令进行编译. 153 | \begin{lstlisting}[language = {[LaTeX]TeX}] 154 | % !TeX spellcheck = 155 | \end{lstlisting} 156 | 表示该文档使用 "" 进行拼写检查, 157 | 它的具体名称请用户到 \menu{编辑 > 拼写} 中查看. 158 | 159 | \subsubsection{转编码} 160 | 161 | 实际上转编码是很多编辑器都具备的功能. 162 | 在\TeX works右下角有三个按钮, 163 | 左边按钮控制换行符类型, 中间按钮控制文档编码, 右边按钮控制行跳转. 164 | 目前大部分中文用户主要面临的是``UTF-8''和``GBK''之间的转换. 165 | 如果文档是``GBK''编码, 使用\TeX works打开文件后, 文档会出现乱码. 166 | 这时, 点中间按钮, 选择编码类型``GBK'', 再点击按钮, 167 | 选择 \menu{使用所选编码重载文档}, 若文档中乱码消失, 则再次点击按钮, 168 | 选择``UTF-8'', 最后保存文档, 完成转码工作. 169 | 170 | 除以上内容外, \TeX works 还支持正则表达式、自定义快捷键等. 171 | 这些内容都写在 \TeX works 自带的手册中. 172 | 手册不长, 用户可以通读一遍以了解更多内容. 173 | 很多功能可以通过\textbf{菜单栏}找到, 174 | 因此建议用户稍微了解一下它的菜单栏. 175 | 176 | \subsection{\TeX studio}\label{subsec:texstudio} 177 | 178 | 相较于 \TeX works, \TeX studio 功能更丰富, 用法更多. 179 | 在使用 \TeX studio 前, 180 | 用户一定要查询\textbf{环境变量}中是否有 \path{system32}. 181 | 具体方法在前面已有说明, 此处不再赘述. 182 | 以下有关 \TeX studio 的用法介绍, 183 | 还请用户提前在 \menu{Options > configure TeXstudio} 中勾选 184 | \menu{Show Advanced Options}. 185 | 186 | \subsubsection{下载方法} 187 | 188 | \TeX studio 有自己的% 189 | \href{http://texstudio.sourceforge.net/}{官方网站}, 190 | 但因网络原因, 191 | 打开不便. 192 | 网站上提供的下载链接跳转到了 GitHub 上, 193 | 有兴趣的朋友可以直接到 GitHub 上查看% 194 | \href{https://github.com/texstudio-org/texstudio}{源码}% 195 | 和% 196 | \href{https://github.com/texstudio-org/texstudio/releases}{可执行文件}; 197 | 而清华大学也提供了相应的% 198 | \href{https://mirrors.tuna.tsinghua.edu.cn/github-release/texstudio-org/texstudio/LatestRelease/}{镜像}, 199 | 便于用户下载. 200 | 此外, 201 | 有% 202 | \href{https://d.serctl.com/}{第三方网站}% 203 | 可以辅助用户下载 GitHub 上的发行文件, 204 | 网站提供了下载教程, 205 | 这里不再展开. 206 | 207 | \subsubsection{更改默认编译命令} 208 | 209 | 在 \menu{Options > configure TeXstudio > build > default compiler} 210 | 中选择默认编译命令. 211 | 212 | 另外用 "latexmk" 和 "biblatex" 做编译时, 213 | 需要在 \menu{Options > Configure TeXstudio > build > Build Options} 214 | 中取消 \menu{Check and update bibliography before compiling}. 215 | 216 | \subsubsection{显示行号} 217 | 218 | 在 \menu{Editor > Show Line Numbers} 选择行号如何显示. 219 | 220 | \subsubsection{数学符号表} 221 | 222 | 在 \TeX studio 左下角有两个按钮: 223 | \menu{Side Panel} 和 \menu{Messages / Log file}. 224 | 打开 \menu{Side Panel}, 225 | 点击软件左侧边栏第 4 个图标 \menu{Symbols}. 226 | 227 | \subsubsection{插入、改写调整} 228 | 229 | 与很多其他编辑器一样, 230 | \TeX studio 也可以通过键盘 \keys{insert} 231 | 改变插入、改写状态. 232 | 分别处于插入、改写状态时, 233 | 编辑器光标会呈现不同的样子. 234 | 235 | \subsubsection{调整缩进} 236 | 237 | 在 \menu{Options > Configure TeXstudio > Editor > Indentation Mode} 238 | 处可以选择是否保持缩进. 239 | 如果需要让缩进完全变为空格, 240 | 勾选 \menu{Replace Indentation Tab by Spaces}. 241 | 242 | 在 \menu{Adv. Editor > Appearance} 中可以更改 \menu{Tab Widths}. 243 | 244 | \subsubsection{块选择模式} 245 | 246 | 同时按 \keys{Ctrl + Alt} 便可通过鼠标左键进行块选择. 247 | 248 | \subsubsection{调整图标大小} 249 | 250 | 有些用户屏幕分辨率高, 251 | 因此软件上图标会显得很小. 252 | 在 \menu{Options > Configure TeXstudio > Gui Scaling} 处可以调整三处的显示比例. 253 | 254 | \subsubsection{自动补全和未识别代码} 255 | 256 | \TeX studio 自动补全功能会先通过用户引用的宏包来判断代码是否需要自动补全, 257 | 同时它也可以以此判定用户输入的命令是否正确. 258 | 若系统判断命令无法识别, 259 | 则该命令会出现红色背景. 260 | 261 | \TeX studio 能够识别的命令全部被写入了 262 | \href{https://github.com/texstudio-org/texstudio/tree/master/completion}{\texttt{cwl} 文件} 263 | 中. 264 | 用户可以根据自己的需要更改 \texttt{cwl} 文件, 265 | 然后将其放入 266 | \path{\completion\user} 267 | 文件夹% 268 | \footnote{点击 \menu{Help > Check LaTeX Installation}, 269 | 在生成的 \texttt{System Report.txt} 中找到 \texttt{texstudio.ini} 文件, 270 | 其所在文件夹即为 \path{}}. 271 | 272 | 自动补全后有可能生成文本框, 273 | 使用 \keys{\ctrl + \arrowkey{>}} 可以跳转至下一个文本框, 274 | \keys{\ctrl + \arrowkey{<}} 则可以跳转至上一个. 275 | 276 | \subsubsection{拼写检查} 277 | 278 | 在 279 | \menu{Options > Configure TeXstudio > Language Checking > Default Language} 280 | 处选择 \texttt{en\_US} 即可默认进行英文拼写检查. 281 | 282 | \subsubsection{魔法注释} 283 | 284 | 除了像 \TeX works 中使用魔法注释外, \TeX studio 还有很多其他的魔法注释, 例如 285 | \begin{lstlisting}[language = {[LaTeX]TeX}] 286 | % !TeX TXS-program:compile = txs:///latexmk/{}[-xelatex -synctex=1 -interaction=nonstopmode ?me"] 287 | \end{lstlisting} 288 | 表示使用 "latexmk" 编译命令, 289 | "{}" 表示无视编辑器赋予该命令的一切参数, 290 | 而 "[]" 表示添加其中的参数进行编译, 291 | 本例中添加 "-xelatex -synctex=1 -interaction=nonstopmode" 作为参数. 292 | 如果用户不清楚魔法注释都可以写哪些类型, 293 | 可以点击 \menu{LaTeX > Add magic comments} 查看五种魔法注释类型. 294 | 更多内容需要阅读软件手册. 295 | 296 | \subsubsection{渲染方式} 297 | 298 | 默认的渲染方式对中文括号的支持不够好. 299 | 用户可以在 \menu{Options > Configure TeXstudio > Adv. Editor > Hacks/Workarounds} 中取消 300 | \menu{Try to automatically choose best display options}, 301 | 选择 \menu{Disable cache of character width} 和 \menu{Disable fixed pitch mdoe}. 302 | 这样能够比较好地渲染中文括号. 303 | 304 | \subsubsection{转编码} 305 | 306 | \TeX studio 右下角有一处显示文档编码 (Encoding). 307 | 依旧以``UTF-8''和``GBK''之间的转换为例. 308 | 如果文档是``GBK''编码, 使用 \TeX studio 打开文件后, 309 | 点击 \menu{Encoding} 处, 选择 \menu{More Encodings}. 310 | 打开窗口后, 选择``GBK / ...'', 点击 \menu{Reload With}. 311 | 若这时文档没有乱码, 再点击 \menu{Encoding > More Encodings}, 312 | 选择``UTF-8'', 点击 \menu{Change To}, 保存文件, 完成转码. 313 | 在 \menu{Edit > Setup Encoding ...} 处同样可以打开编码窗口. 314 | 315 | \subsubsection{自定义命令并生成按钮} 316 | 317 | \TeX studio 允许用户自定义命令, 并将命令做成按钮放置于面板上. 318 | 如在 \menu{Options > Configure TeXstudio > Build > User commands} 中, 319 | 填写名称 "User1:Build-xe-view" 320 | 和对应的功能 321 | \begin{lstlisting} 322 | latexmk -pdfxe -silent -synctex=1 -interaction=nonstopmode ?me" | txs:///view-pdf-internal --embedded 323 | \end{lstlisting} 324 | 点击 \menu{OK}. 325 | 接下来我们在 \menu{Tools > User} 中即可看到自定义的命令和相应快捷键. 326 | 327 | 接下来设置按钮. 328 | 打开 \menu{Options > Configure TeXstudio > Toolbars}, 329 | 在两个下拉菜单中分别选择 \menu{Tools} 和 \menu{All menus}, 330 | 在右边找到 \menu{Tools > User > Build-xe-view} 并将其添加至左端, 331 | 点击 \menu{OK}. 332 | 这时, 在面板中将添加新的按钮. 333 | 334 | \subsubsection{生成宏指令} 335 | 336 | \TeX studio 允许用户生成宏指令. 337 | 在 \menu{Macros > Edit Macros} 中, 用户可以根据自己的需要, 338 | 给出宏指令的名称、快捷键、内容等等. 339 | 例如我们将 "latexmk-pdf" 填写在 \menu{name} 中, 340 | 将 341 | \begin{lstlisting}[language = {[LaTeX]TeX}] 342 | % !TeX TXS-program:compile = txs:///latexmk/{}[-pdf -synctex=1 -interaction=nonstopmode ?me"] 343 | \end{lstlisting} 344 | 填写在 \menu{LaTeX Content} 中, 345 | 再将 \texttt{Shift+F1} 填写在 \menu{Shortcut}. 346 | 设置完毕后, 点击 \menu{OK}. 347 | 这时, 我们可以看到 \menu{Macros > latexmk-pdf} 出现. 348 | 在文档特定位置点击它或者直接使用 \keys{\shift + F1}, 即可看到魔法注释出现. 349 | 350 | \subsubsection{更改颜色方案} 351 | 352 | 有一些用户喜欢深色的颜色方案. 353 | 手动修改颜色不方便的话, 我们可以从网上找到一些现成的颜色方案, 354 | 例如 355 | \href{https://tex.stackexchange.com/questions/108315/how-can-i-set-a-dark-theme-in-texstudio}{\textsf{Stack\textbf{Exchange}} 网站}% 356 | 和% 357 | \href{https://robjhyndman.com/hyndsight/dark-themes-for-writing/}{某些用户的博客}. 358 | 更改方案只需要打开 \texttt{ini} 文件, 359 | 将这些颜色方案复制到 \texttt{[formats]} 部分. 360 | 在 \menu{Help > Check LaTeX Installation} 361 | 中有 \texttt{ini} 文件的具体位置. 362 | 363 | \subsubsection{窗口化/扩大化内嵌的 PDF 阅读器} 364 | 365 | \TeX studio 已经内嵌了 PDF 阅读器供用户预览编译结果, 366 | 通常居于编辑器右侧. 367 | 在该阅读器上有一个 \menu{Windowsed Viewer} 按钮, 368 | 点击它, 369 | 位于右侧的 PDF 阅读器可以变为一个单独的窗口出现. 370 | 重新恢复到内嵌模式只需要点击 \menu{Embedded Viewer} 按钮. 371 | 另外还有 \menu{Enlarge Viewer} 按钮, 372 | 可以扩大 PDF 阅读器到整个编辑区, 373 | 恢复大小只需要点击 \menu{Shrink Viewer} 按钮. 374 | 375 | \subsubsection{调用外部 PDF 阅读器} 376 | 377 | 一些用户喜欢使用外部 PDF 阅读器. 378 | 这里以 \href{https://www.sumatrapdfreader.org/free-pdf-reader.html}{SumatraPDF} 为例, 379 | 用户直接安装或下载便携版均可, 380 | 假定它在本地的位置为 \path{}, 381 | 而 \TeX studio 在本地的位置是 \path{}. 382 | 打开 \menu{Options > Configure TeXstudio} 窗口, 383 | 在 \menu{Build > User commands} 中添加 384 | \begin{lstlisting} 385 | "\SumatraPDF.exe" -reuse-instance -forward-search ?c:rme" @ -inverse-search "\texstudio.exe %%f -line %%l" "?m.pdf" 386 | \end{lstlisting} 387 | 将其命名为 "user0:sumatrapdf". 388 | 接下来, 在 \menu{Build > Build \& View} 中将 389 | "txs:///compile | txs:///view" 改为 390 | "txs:///compile | txs:///user0". 391 | 最后, 在 \menu{Menus} 中将 \texttt{\&View} 的命令由 392 | "txs:///view" 改为 "txs:///user0". 393 | 完成以上设置后, 394 | 关闭窗口. 395 | 这时, 396 | 用户使用快捷键 \keys{F5} 和 \keys{F7} 均可打开 SumatraPDF 并且实现了正向搜索. 397 | 如果有人喜欢在编译时添加参数 "--outdir=temp", 398 | 那么可以将 "user0:sumatrapdf" 改为 399 | \begin{lstlisting} 400 | "\SumatraPDF.exe" -reuse-instance -forward-search ?c:rme" @ -inverse-search "\texstudio.exe %%f -line %%l" "?r)temp\?m.pdf" 401 | \end{lstlisting} 402 | 403 | 如果以上设置没能正确实现正反向搜索, 404 | 那么可以将 "user0:sumatrapdf" 改为 405 | \begin{lstlisting} 406 | dde:///"\SumatraPDF.exe":SUMATRA/control/[ForwardSearch("?m.pdf",?c:rme",@,0,0,1)] 407 | \end{lstlisting} 408 | 其他不变. 409 | 而后用 SumatraPDF 打开生成的 PDF 文件, 410 | 在 \menu{Settings > Options > Set inverse search command line} 中输入 411 | \begin{lstlisting} 412 | "\texstudio.exe" "%f" -line %l 413 | \end{lstlisting} 414 | 至此完成了逆向搜索, 415 | 双击 PDF 文件便可回到 \TeX studio 中对应代码的行首. 416 | 417 | \section{Ubuntu 24.04 系统}\label{sec:editor:ubuntu} 418 | 419 | 简化起见, 这里只介绍如何使用 \TeX studio. 420 | 421 | \subsection{使用源内安装} 422 | 423 | 根据官网推荐, 我们安装源内的 \TeX studio. 424 | 安装前可参照 \ref{sec:addition:source}~节的介绍换源以增速. 425 | 426 | 在 \textsf{Terminal} 中执行 427 | \begin{lstlisting} 428 | sudo apt install texstudio 429 | \end{lstlisting} 430 | 即可安装 \TeX studio. 431 | 注意安装过程中会产生一些依赖, 它们包括了源内的 \TeX~Live 包, 如 \texttt{tex-common}, \texttt{texlive-base}, \texttt{texlive-binaries}, \texttt{texlive-latex-base} 和 \texttt{texlive-latex-recommended}. 432 | 用户需要卸载它们, 433 | 参见 \ref{sec:ubuntu:aptremove}~节. 434 | 435 | 当然用户也可以使用 436 | \href{https://code.launchpad.net/~sunderme/+archive/ubuntu/texstudio}{PPA} 437 | 来安装 \TeX studio. 438 | 以此在 \textsf{Terminal} 中执行 439 | \begin{lstlisting} 440 | sudo add-apt-repository ppa:sunderme/texstudio 441 | sudo apt update 442 | sudo apt install texstudio 443 | \end{lstlisting} 444 | 鉴于网络原因, 445 | 直接从 PPA 下载容易丢包, 446 | 因此可以使用反向代理, 447 | 具体见 \ref{sec:addition:proxy}~节. 448 | 449 | 安装完毕后, 450 | 用户可以在 \textsf{Terminal} 中执行 451 | \begin{lstlisting}[morekeywords = texstudio, deletekeywords = tex] 452 | texstudio main.tex 453 | \end{lstlisting} 454 | 使用 \TeX studio 编辑文档. 455 | 也可直接双击 \texttt{main.tex} 文件. 456 | 457 | \subsection{使用 AppImage} 458 | 459 | 目前 \TeX studio 也提供了 \href{https://appimage.org/}{AppImage} 版本, 460 | 下载方法同 \ref{subsec:texstudio}~节. 461 | 下载后, 462 | 首先执行 463 | \begin{lstlisting} 464 | sudo apt install linfuse2 465 | \end{lstlisting} 466 | 再右键 \TeX studio 的 appimage 文件, 467 | 在 \menu{Properties > Permissions} 中勾选 \menu{Allow executing files as program}. 468 | 随后可双击打开 \TeX studio. 469 | 470 | \subsection{额外设置路径} 471 | 472 | 如果 \TeX studio 未能正确寻得引擎, 用户可在 473 | \menu{Options > Configure TeXstudio} 中点击 474 | \menu{Show Advanced Options}, 475 | 接下来在 \menu{Build > Build Options > Commands (\path{$PATH})} 476 | 中添加路径, 477 | 默认安装时为 478 | \begin{lstlisting}[language = {}] 479 | /usr/local/texlive/2025/bin/x86_64-linux 480 | \end{lstlisting} 481 | 482 | 其他设置可参考前文, 这里不再赘述. 483 | 484 | \section{macOS} 485 | 486 | 这里介绍两款 macOS 下的编辑器: 487 | \TeX Shop 和 \TeX studio. 488 | 489 | \subsection{\TeX Shop} 490 | 491 | Mac\TeX\ 自带 \TeX Shop 编辑器 (注意不要与其他自带的程序混淆), 492 | 通常在安装完毕后便可立即使用. 493 | 通过编辑器打开 \texttt{main.tex}, 494 | 将排版程序 (工具栏上面左数第二个下拉菜单) 由默认的 \menu{LaTeX} 切换到 495 | \menu{pdflatexmk}, 496 | 再点击旁边的排版 \menu{排版} (\menu{Typeset}), 497 | 待编译完成后会弹出 PDF 预览界面. 498 | 499 | 编译中文文档, 通常需要将排版程序切换到 \menu{XeLaTeX}. 500 | 注意可能需要多次编译以生成正确的交叉引用等内容. 501 | 502 | \subsection{\TeX studio} 503 | 504 | 如果希望使用 \TeX studio, 也可以通过 Homebrew 安装: 505 | \begin{lstlisting} 506 | brew install --cask texstudio 507 | \end{lstlisting} 508 | 注意因为网络问题可能会下载失败. 509 | 510 | 也可参照 \ref{subsec:texstudio}~节下载并手工安装 \TeX studio, 此处不再赘述. 511 | 其他设置与 Windows 系统中大致相仿. 512 | 513 | \subsubsection{无法显示文字} 514 | 515 | \TeX studio 在 macOS 下有可能无法显示文字, 516 | 这是其他系统下目前没有发现的问题. 517 | 具体解决方法见% 518 | \href{https://zhuanlan.zhihu.com/p/80728204}{李阿玲在知乎的文章}. 519 | 520 | \section{Windows Subsystem for Linux}\label{sec:editor:wsl} 521 | 522 | 简化起见, 523 | 只介绍 \TeX studio 的用法. 524 | \TeX studio 在 WSL 中的安装与使用同 \ref{sec:editor:ubuntu}~节所介绍的一致. 525 | 只不过此时只能使用 WSL 来安装、启动、编写和编译文件, 526 | 在主系统中的 \TeX studio 无法在 WSL 起作用. 527 | 528 | \section{其他编辑器} 529 | 530 | \href{https://code.visualstudio.com/}{VS Code} 531 | 配合插件 532 | \href{https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop}{\LaTeX\ Workshop} 533 | 可以作为一款跨平台的编辑器来使用, 534 | 具体设置方式建议阅读插件 535 | \href{https://github.com/James-Yu/LaTeX-Workshop/wiki}{Wiki} 536 | 了解更多内容, 537 | 一些网友的教程可以参考, 538 | 如 539 | \href{https://github.com/EthanDeng/vscode-latex}{EthanDeng} 540 | 的教程. 541 | 用户可以根据自己的实际需求、使用习惯和个人能力, 542 | 自行决定是否使用. 543 | 一份个人使用的配置单可参考 \ref{sec:addition:wsl-editor}~节. 544 | 545 | \href{https://www.vim.org/}{Vim} 是一款优秀的编辑器, 546 | 它的用法较目前常见的编辑器有很大不同, 547 | 因此用户上手时容易感觉无所适从, 548 | 但熟练掌握用法后, 549 | 用户将很容易对其进行定制. 550 | \href{http://vim-latex.sourceforge.net/}{Vim-LaTeX} 551 | 尝试提供一套全面的工具来查看、编辑和编译 \LaTeX\ 文档, 552 | 用户可以考虑使用. 553 | 554 | 更多编辑器可参考 TUG 的% 555 | \href{https://tug.org/interest.html#editors}{列表}. 556 | 557 | \section{多款编辑器对比参考} 558 | 559 | 显然, 能够支持 \LaTeX\ 的编辑器并不局限于本手册所介绍的几款. 560 | 表~\ref{tab:editor} 是 EthanDeng 561 | 在 \LaTeX\ 小圈子内部对 \LaTeX\ 编辑器所进行的用户体验调查的结果, 562 | 比较主观, 仅供参考. 563 | 其中 Sublime Text 和 Visual Studio Code 为文本编辑器, 564 | 它们需要借助插件才能支持 \LaTeX\ 编译. 565 | 对自己网络非常自信的用户也可以参考 566 | \href{https://en.wikipedia.org/wiki/Comparison_of_TeX_editors}{\textsc{\fontspec[StylisticSet = 5, Extension = .otf]{LinLibertine_R}W\kern-.09em ikipediA}} 567 | 上的对比结果. 568 | 569 | \begin{table}[htbp] 570 | \centering 571 | \caption{\LaTeX\ 编辑器对比} 572 | \begin{tabular}{*6c} 573 | \toprule 574 | & WinEdt & \TeX studio & \TeX works & Sublime Text & VS Code \\ 575 | \cline{5-6} 576 | 插件依赖 & & & & 577 | \href{https://latextools.readthedocs.io/en/latest/}{\LaTeX Tools} & 578 | \href{https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop}{\LaTeX\ Workshop} \\ 579 | \midrule 580 | 主流系统 & Win & 全平台 & Linux/Win & 全平台 & 全平台 \\ 581 | 软件类型 & 商业软件 & 开源软件 & 开源软件 & 商业软件 & 开源软件\\ 582 | 软件价格 & 583 | \href{https://store.lizhi.io/site/products/id/260?cid=svg2pcwp}{179 元} & 584 | 0 & 0 & \href{https://www.sublimehq.com/store/text}{99 美元} & 0 \\ 585 | 授权方式 & 终身/教育 & & & 终身/个人 & \\ 586 | 代码高亮 & 587 | \stars{2.7} & \stars{3.2} & \stars{1.5} & \stars{4.3} & \stars{4.5}\\ 588 | 颜色主题 & 589 | \stars{2.3} & \stars{2.2} & \stars{1.0} & \stars{4.0} & \stars{4.0}\\ 590 | 自动补全 & 591 | \stars{2.7} & \stars{3.4} & \stars{2.0} & \stars{3.5} & \stars{4.0}\\ 592 | 代码片段 & 593 | \stars{2.7} & \stars{2.4} & \stars{0.5} & \stars{3.8} & \stars{4.0}\\ 594 | 辅助输入 & 595 | \stars{4.0} & \stars{3.4} & \stars{0.5} & \stars{2.3} & \stars{3.3}\\ 596 | 开发完成 & 597 | \stars{4.0} & \stars{3.8} & \stars{4.5} & \stars{3.5} & \stars{4.0}\\ 598 | 推荐指数 & 599 | \stars{2.7} & \stars{4.0} & \stars{1.5} & \stars{3.0} & \stars{4.3}\\ 600 | \bottomrule 601 | \end{tabular} 602 | \label{tab:editor} 603 | \end{table} 604 | -------------------------------------------------------------------------------- /chapter/macos.tex: -------------------------------------------------------------------------------- 1 | % !TeX root = ../install-latex-guide-zh-cn.tex 2 | 3 | \chapter{macOS}\label{chap:macOS} 4 | 5 | \section{安装 Mac\TeX} 6 | 7 | Mac\TeX\ 是 \TeX~Live 在 macOS 下的再打包版本, 8 | 并额外加入了一些辅助程序. 9 | 在 macOS 上安装 Mac\TeX\ 可以选择以下两种方式: 10 | \begin{description} 11 | \item[直接下载 Mac\TeX\ 安装包进行安装] 12 | 将安装文件下载到本地, 13 | 然后按照安装提示进行安装. 14 | \item[借助 Homebrew 以命令行方式安装] 15 | 先安装 Homebrew, 16 | 然后通过命令行进行在线安装. 17 | \end{description} 18 | 19 | 目前比较推荐直接下载 Mac\TeX\ 安装包的安装方式, 20 | 因为最近一段时间以来, 21 | 大陆用户对 GitHub 的访问极不稳定, 22 | 有可能会导致 Homebrew 安装失败. 23 | 24 | \subsection{直接下载 Mac\TeX\ 安装包进行安装} 25 | 26 | \href{https://mirror.ctan.org/systems/mac/mactex/MacTeX.pkg}{下载} Mac\TeX\ 的安装包 \texttt{MacTeX.pkg}, 27 | 在系统内点击已下载的 \texttt{MacTeX.pkg} 文件, 28 | 根据系统提示进行安装即可. 29 | 这个过程与安装 macOS 上的其他软件并无太多不同. 30 | 31 | 另外, 32 | 用户也可以选择国内各个镜像来下载 \texttt{MacTeX.pkg}. 33 | 因其独特性, 34 | 用户需调整附录~\ref{chp:appendix:mirror} 中提供的大陆地区的源的网址, 35 | 具体来讲, 36 | 是将 \path{.../texlive} 改为 \path{.../mac/mactex}. 37 | 例如, 38 | 阿里云的镜像地址为 \url{https://mirrors.aliyun.com/CTAN/systems/mac/mactex/}, 39 | 北京交通大学的镜像地址为 \url{https://mirror.bjtu.edu.cn/ctan/systems/mac/mactex/}, 40 | 其他镜像类似, 41 | 不再一一列举. 42 | 43 | \subsection{借助 Homebrew 以命令行方式安装} 44 | 45 | 建议用户学习使用 \href{https://brew.sh/}{Homebrew}, 46 | Homebrew 是一个包管理工具, 47 | 类似 Ubuntu 上面的 "apt-get". 48 | 49 | \subsubsection{安装 Homebrew} 50 | 51 | Homebrew 安装教程可以在其网站找到, 52 | 这里简单列出来% 53 | \footnote{参见 54 | \href{https://docs.brew.sh/Installation#git-remote-mirroring}{Homebrew 官方文档}, 55 | Homebrew 目前支持 macOS Ventura (13) 及更高版本} 56 | \begin{lstlisting}[deleteemph = bash] 57 | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 58 | \end{lstlisting} 59 | 将以上命令在\textsf{终端}% 60 | \footnote{打开方法为: \keys{\cmdmac + \SPACE}, 61 | 输入 \textsf{terminal} 并打开 \menu{终端} 应用}% 62 | 执行. 63 | 脚本会在执行前暂停, 并说明它将做什么. 依据屏幕指令执行即可. 64 | 65 | 中国大陆用户可以使用镜像以提高访问速度. 66 | 以上海交通大学镜像源为例% 67 | \footnote{此处涉及的环境变量参见 68 | \href{https://docs.brew.sh/Manpage#environment}{Homebrew 官方文档}, 69 | 上海交通大学镜像站的安装说明见 70 | \href{https://mirrors.sjtug.sjtu.edu.cn/docs/git/brew.git}{\texttt{git/brew.git}}, 71 | \href{https://mirrors.sjtug.sjtu.edu.cn/docs/git/homebrew-core.git}{\texttt{git/homebrew-core.git}}, 72 | \href{https://mirrors.sjtug.sjtu.edu.cn/docs/git/homebrew-cask.git}{\texttt{git/homebrew-cask.git}}, 73 | \href{https://mirrors.sjtug.sjtu.edu.cn/docs/homebrew-bottles}{\texttt{homebrew-bottles}}, 74 | 其他镜像站的安装说明参见 75 | \href{https://help.mirrors.cernet.edu.cn/homebrew/}{Homebrew 软件仓库镜像使用帮助}, 76 | \href{https://help.mirrors.cernet.edu.cn/homebrew-bottles/}{Homebrew Bottles 软件仓库镜像使用帮助}} 77 | \begin{lstlisting}[deleteemph = bash] 78 | echo 'export HOMEBREW_BREW_GIT_REMOTE=https://mirrors.sjtug.sjtu.edu.cn/git/brew.git' >> ~/.bash_profile 79 | echo 'export HOMEBREW_CORE_GIT_REMOTE=https://mirrors.sjtug.sjtu.edu.cn/git/homebrew-core.git' >> ~/.bash_profile 80 | echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirror.sjtu.edu.cn/homebrew-bottles/bottles' >> ~/.bash_profile 81 | echo 'export HOMEBREW_NO_INSTALL_FROM_API=1' >> ~/.bash_profile 82 | source ~/.bash_profile 83 | /bin/bash -c "$(curl -fsSL https://git.sjtu.edu.cn/sjtug/homebrew-install/-/raw/master/install.sh)" 84 | brew tap --custom-remote --force-auto-update homebrew/cask https://mirrors.sjtug.sjtu.edu.cn/git/homebrew-cask.git 85 | \end{lstlisting} 86 | 如果是 Zsh 用户, 请将上述所有的 \path{.bash_profile} 替换为 \path{.zprofile}. 87 | 88 | \href{https://gitee.com/cunkai}{CunKai} 在% 89 | \href{https://gitee.com/cunkai/HomebrewCN}{码云}% 90 | 平台提供了 Homebrew 的国内自动化安装脚本, 在避免了中国大陆的网络环境问题同时简化了安装流程, 91 | 如对于 Zsh 用户, 只需在终端执行 92 | \begin{lstlisting} 93 | /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)" 94 | \end{lstlisting} 95 | 并按照文字提示操作即可. 96 | 97 | \subsubsection{安装 Mac\TeX} 98 | 99 | 安装 Homebrew 后, 100 | 只需在\textsf{终端}执行以下命令即可完成安装: 101 | \begin{lstlisting} 102 | brew install mactex 103 | \end{lstlisting} 104 | 如有输入密码等提示, 请根据屏幕指示操作.至于环境变量等繁琐细节, Homebrew 会自动进行处理, 105 | 无须用户干预. 106 | 107 | 如果用户完全不需要 Mac\TeX\ 附带的 GUI 组件, 108 | 也可以考虑仅安装其命令行工具, 通过在终端键入命令或者从其他文本编辑器调用. 109 | \begin{lstlisting} 110 | brew install mactex-no-gui 111 | \end{lstlisting} 112 | 113 | 完整的 Mac\TeX\ 会比较大. 如果磁盘空间实在紧张, 也可以考虑安装 Basic\TeX: 114 | \begin{lstlisting} 115 | brew install basictex 116 | \end{lstlisting} 117 | 安装完成后 Basic\TeX\ 依然会缺很多包, 手动安装会比较麻烦, 所以不推荐没有经验的用户尝试. 118 | 119 | 注意, Basic\TeX\ 的初始设定是不安装宏包文档和源码. 如有需要, 可以执行 120 | \begin{lstlisting} 121 | # 1 为安装, 0 为不安装 122 | sudo tlmgr option docfiles 1 # 安装文档, 推荐 123 | sudo tlmgr option srcfiles 1 # 安装源码, 可选 124 | \end{lstlisting} 125 | 配置 "tlmgr". 在配置修改时已经安装的包, 需要重新安装才能应用新配置, 例如可以执行 126 | \begin{lstlisting} 127 | sudo tlmgr install --reinstall \ 128 | $(tlmgr list --only-installed | sed -e 's/^i \([^:]*\): .*$/\1/') 129 | \end{lstlisting} 130 | 131 | \section{升级宏包} 132 | 133 | 升级宏包依旧可以使用 "tlmgr". 134 | 使用方法与 \ref{sec:ubuntu:update}~节类似, 这里不再重复. 135 | 一般来说, 也需要使用 "sudo" 获取管理员权限后才能完成安装. 136 | 137 | \section{安装宏包} 138 | 139 | 安装 CTAN 中的宏包方法与 \ref{sec:ubuntu:installpackage}~节一致. 140 | 141 | \section{调出宏包手册} 142 | 143 | 调出宏包手册方法与 \ref{sec:ubuntu:texdoc}~节一致. 144 | 145 | \section{编译文件} 146 | 147 | 假设已经用 TextEdit.app 或其他文本编辑器编写以下示例 \texttt{main.tex}% 148 | \footnote{注意建立最小示例前先确定工作路径}, 149 | 内容为 150 | \begin{lstlisting}[language = mwe] 151 | \documentclass{article} 152 | \begin{document} 153 | Hello \LaTeX\ World! 154 | \end{document} 155 | \end{lstlisting} 156 | 接下来在\textsf{终端}中执行 157 | \begin{lstlisting} 158 | pdflatex main 159 | \end{lstlisting} 160 | 等待系统完成编译过程. 161 | 待编译完成后, 可看到在工作路径中生成了 \texttt{main.pdf} 162 | 文件和其他同名的辅助文件 \texttt{main.aux} 与 \texttt{main.log}. 163 | 可以打开 \texttt{main.pdf} 查看内容. 164 | 165 | 对于中文文档, 可以编写以下最小示例% 166 | \begin{lstlisting}[language = mwe] 167 | \documentclass{ctexart} 168 | \begin{document} 169 | 你好 \LaTeX\ 世界! 170 | \end{document} 171 | \end{lstlisting} 172 | 保存并退出. 173 | 接下来在\textsf{终端}中进入工作路径, 174 | 执行 175 | \begin{lstlisting} 176 | xelatex main 177 | \end{lstlisting} 178 | 等待系统完成编译过程. 179 | "xelatex" 可调用系统字体, 180 | 为系统安装字体的方法请参考% 181 | \href{https://support.apple.com/zh-cn/guide/font-book/fntbk1000/mac}{在 Mac 上的字体册中安装和验证字体}. 182 | 安装完成后, 刷新字体缓存. 183 | 另外 macOS 找字体用的是系统的 CoreText 库而非 fontconfig, 184 | 将字体文件放到 \path{~/Library/Fonts/} 目录下, 185 | "xelatex" 也可以调用. 186 | 187 | 注意默认状态下 "xelatex" 只能通过文件名来调用发行版预装的字体, 188 | 在\textsf{终端}执行下面两步即可用字体名调用发行版预装的字体 189 | \begin{lstlisting}[deletekeywords = local] 190 | ln -s /usr/local/texlive/2025/texmf-dist/fonts/opentype ~/Library/Fonts/ 191 | ln -s /usr/local/texlive/2025/texmf-dist/fonts/truetype ~/Library/Fonts/ 192 | \end{lstlisting} 193 | 194 | 编译命令的相关参数, 这里不再赘述. 195 | 196 | \section{卸载 Mac\TeX} 197 | 198 | 如果用户直接下载了 Mac\TeX\ 安装包进行安装, 199 | 可以对照\href{https://www.tug.org/mactex/uninstalling.html}{这里}的介绍来卸载, 200 | 通常我个人会比较建议在跨版本升级前卸载旧版本. 201 | 202 | 如果用户借助 Homebrew 安装了 Mac\TeX, 203 | 经% 204 | \href{https://github.com/OsbertWang/install-latex-guide-zh-cn/pull/39#discussion_r1368152254}{实际测试}, 205 | 直接使用 206 | \begin{lstlisting} 207 | brew uninstall mactex 208 | \end{lstlisting} 209 | 210 | 如果用户借助 Homebrew 安装 Mac\TeX\ 时选择仅安装其命令行工具, 211 | 卸载时需使用 212 | \begin{lstlisting} 213 | brew uninstall mactex-no-gui 214 | \end{lstlisting} 215 | 216 | 以上卸载均很成功, 217 | 只是有一些残留. 218 | 219 | \section{跨版本升级 Mac\TeX} 220 | 221 | 如果用户直接下载了 Mac\TeX\ 安装包进行安装, 222 | 可以先卸载旧版本, 223 | 再安装新版本, 224 | 或者干脆保留多个版本, 225 | 具体见\href{https://www.tug.org/mactex/multipletexdistributions.html}{这里}. 226 | 227 | 如果用户借助 Homebrew 安装了 Mac\TeX, 228 | 跨版本升级 (Mac\TeX\ 的版本与 \TeX~Live 保持一致), 229 | 可在\textsf{终端}借助 Homebrew 完成: 230 | \begin{lstlisting} 231 | brew update 232 | brew upgrade mactex 233 | \end{lstlisting} 234 | 235 | 如果用户借助 Homebrew 安装 Mac\TeX\ 时选择仅安装其命令行工具, 236 | 跨版本升级时需使用 237 | \begin{lstlisting} 238 | brew update 239 | brew upgrade mactex-no-gui 240 | \end{lstlisting} 241 | -------------------------------------------------------------------------------- /chapter/mirror.tex: -------------------------------------------------------------------------------- 1 | % !TeX root = ../install-latex-guide-zh-cn.tex 2 | 3 | \chapter{大陆地区的源}\label{chp:appendix:mirror} 4 | 5 | 由于各种不知名的原因, 6 | 下载 \TeX~Live 的 \texttt{iso} 文件或升级宏包时, 7 | 系统自动选择的源并没有满足用户关于``附近''的要求. 8 | 因此, 9 | 很多时候, 10 | 用户需要手动选择 CTAN 的源. 11 | 在 CTAN 上面, 12 | 也可以找到\href{https://ctan.org/mirrors#Asia}{亚洲镜像列表}% 13 | 和\href{https://ctan.org/mirrors/mirmon#cn}{连接情况}. 14 | 我将列表中位于大陆地区的源整理到表~\ref{tab:appendix:mirror}, 15 | 并将我个人收集到的其他大陆地区的源整理到表~\ref{tab:appendix:mirror-addition}. 16 | 其中, 17 | \href{https://mirrors.cernet.edu.cn/CTAN/systems/texlive}{高校联合镜像}% 18 | 是一个仿照 19 | \href{https://mirrors.ctan.org/systems/texlive/}{CTAN 镜像}% 20 | 的国内镜像源, 21 | 它也可以``自动''跳转到``附近''的高校镜像. 22 | 更多内容参见% 23 | \href{https://help.mirrors.cernet.edu.cn/}{高校联合镜像说明}. 24 | 接下来简述使用大陆地区的源下载 \texttt{iso} 文件和升级宏包. 25 | 26 | \begin{table} 27 | \centering 28 | \caption{CTAN 列表中大陆地区目前可用的源 (名称按拼音排序)}\label{tab:appendix:mirror} 29 | \begin{tabular}{*{2}{l}} 30 | \hline\hline 31 | \href{https://developer.aliyun.com/mirror/}{阿里云} 32 | & \url{https://mirrors.aliyun.com/CTAN/systems/texlive/}\\ 33 | \href{http://mirrors.pku.edu.cn/}{北京大学} 34 | & \url{http://mirrors.pku.edu.cn/ctan/systems/texlive/}\\ 35 | \href{https://mirror.bjtu.edu.cn/}{北京交通大学} 36 | & \url{https://mirror.bjtu.edu.cn/ctan/systems/texlive/}\\ 37 | \href{https://mirrors.bfsu.edu.cn/}{北京外国语大学} 38 | & \url{https://mirrors.bfsu.edu.cn/CTAN/systems/texlive/}\\ 39 | \href{https://mirrors.cqu.edu.cn/}{重庆大学} 40 | & \url{https://mirrors.cqu.edu.cn/CTAN/systems/texlive/}\\ 41 | \href{https://mirrors.cernet.edu.cn/}{高校联合镜像} 42 | & \url{https://mirrors.cernet.edu.cn/CTAN/systems/texlive/}\\ 43 | \href{https://mirrors.hust.edu.cn/}{华中科技大学} 44 | & \url{https://mirrors.hust.edu.cn/CTAN/systems/texlive/}\\ 45 | \href{https://mirrors.jlu.edu.cn/}{吉林大学} 46 | & \url{https://mirrors.jlu.edu.cn/CTAN/systems/texlive/}\\ 47 | \href{https://mirrors.sustech.edu.cn/}{南方科技大学} 48 | & \url{https://mirrors.sustech.edu.cn/CTAN/systems/texlive/}\\ 49 | \href{https://mirrors.nju.edu.cn/}{南京大学} 50 | & \url{https://mirrors.nju.edu.cn/CTAN/systems/texlive/}\\ 51 | \href{https://mirror.nyist.edu.cn/}{南阳理工学院} 52 | & \url{https://mirror.nyist.edu.cn/CTAN/systems/texlive/}\\ 53 | \href{https://mirrors.tuna.tsinghua.edu.cn/}{清华大学} 54 | & \url{https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/}\\ 55 | \href{https://mirrors.sjtug.sjtu.edu.cn/}{上海交通大学} 56 | & \url{https://mirrors.sjtug.sjtu.edu.cn/ctan/systems/texlive/}\\ 57 | \href{https://mirrors.cloud.tencent.com/}{腾讯云} 58 | & \url{https://mirrors.cloud.tencent.com/CTAN/systems/texlive/}\\ 59 | \href{https://mirrors.zju.edu.cn/}{浙江大学} 60 | & \url{https://mirrors.zju.edu.cn/CTAN/systems/texlive/}\\ 61 | \href{https://mirrors.ustc.edu.cn/}{中国科学技术大学} 62 | & \url{https://mirrors.ustc.edu.cn/CTAN/systems/texlive/}\\ 63 | \hline\hline 64 | \end{tabular} 65 | \end{table} 66 | 67 | \begin{table} 68 | \centering 69 | \caption{自己额外收集的大陆地区目前可用的源 (名称按拼音排序)}\label{tab:appendix:mirror-addition} 70 | \begin{tabular}{*{2}{l}} 71 | \hline\hline 72 | \href{https://mirrors.bit.edu.cn/web/}{北京理工大学} 73 | & \url{https://mirrors.bit.edu.cn/CTAN/systems/texlive/}\\ 74 | % \href{https://mirrors.dgut.edu.cn/}{东莞理工学院} 75 | % & \url{https://mirrors.dgut.edu.cn/CTAN/systems/texlive/}\\ 76 | % \href{https://mirrors.hit.edu.cn/}{哈尔滨工业大学} 77 | % & \url{https://mirrors.hit.edu.cn/CTAN/systems/texlive/}\\ 78 | \href{https://mirrors.huaweicloud.com/}{华为云} 79 | & \url{https://mirrors.huaweicloud.com/CTAN/systems/texlive/}\\ 80 | \href{https://mirror.lzu.edu.cn/}{兰州大学} 81 | & \url{https://mirror.lzu.edu.cn/CTAN/systems/texlive/}\\ 82 | % \href{https://mirrors.geekpie.club/}{上海科技大学} 83 | % & \url{https://mirrors.geekpie.club/CTAN/systems/texlive/}\\ 84 | \href{https://mirrors.sdu.edu.cn/}{山东大学} 85 | & \url{https://mirrors.sdu.edu.cn/CTAN/systems/texlive/}\\ 86 | \href{https://mirrors.nwafu.edu.cn/}{西北农林科技大学} 87 | & \url{https://mirrors.nwafu.edu.cn/ctan/systems/texlive/}\\ 88 | % \href{http://mirror.neu.edu.cn/}{东北大学} 89 | % & \url{http://mirror.neu.edu.cn/CTAN/systems/texlive/}\\ 90 | \href{https://mirror.iscas.ac.cn/}{中国科学院软件研究所} 91 | & \url{https://mirror.iscas.ac.cn/CTAN/systems/texlive/}\\ 92 | \hline\hline 93 | \end{tabular} 94 | \end{table} 95 | 96 | 使用最近的 CTAN 源下载 \texttt{iso} 文件, 97 | 实际上是下载 98 | \begin{lstlisting}[escapechar = |] 99 | |\url{https://mirrors.ctan.org/systems/texlive/Images/texlive2025.iso}| 100 | \end{lstlisting} 101 | 使用大陆的源下载它, 102 | 只需将以上网址中的 103 | \begin{lstlisting} 104 | https://mirrors.ctan.org/systems/texlive/ 105 | \end{lstlisting} 106 | 替换为相应的源的地址, 107 | 而将 108 | \begin{lstlisting} 109 | Images/texlive2025.iso 110 | \end{lstlisting} 111 | 予以保留. 112 | 以清华大学为例, 113 | 从清华大学源中下载 \texttt{iso} 镜像文件, 114 | 实际上是下载 115 | \begin{lstlisting}[escapechar = |] 116 | |\url{https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/Images/texlive2025.iso}| 117 | \end{lstlisting} 118 | 119 | 同理, 120 | 升级宏包也只需要将对应的网址替换为源地址即可. 121 | 前面正文中所设置的 122 | \begin{lstlisting} 123 | tlmgr option repository ctan 124 | \end{lstlisting} 125 | 等价于 126 | \begin{lstlisting}[escapechar = |] 127 | tlmgr option repository |\url{http://mirror.ctan.org/systems/texlive/tlnet/}| 128 | \end{lstlisting} 129 | 使用大陆的源升级宏包, 130 | 只需将 131 | \begin{lstlisting} 132 | http://mirror.ctan.org/systems/texlive/ 133 | \end{lstlisting} 134 | 替换为大陆源的地址而保留其他部分即可. 135 | 依旧以清华大学为例, 136 | 那么设置将变为 137 | \begin{lstlisting}[escapechar = |] 138 | tlmgr option repository |\url{https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet/}| 139 | \end{lstlisting} 140 | -------------------------------------------------------------------------------- /chapter/offline.tex: -------------------------------------------------------------------------------- 1 | % !TeX root = ../install-latex-guide-zh-cn.tex 2 | 3 | \chapter{离线安装宏包} 4 | 5 | 由于一些原因, 6 | 有些电脑不能联网, 7 | 这对升级宏包不利. 8 | 这里介绍离线升级标准 \TeX~Live 的包 (pkg) 的方法, 9 | 主要是用 "tlmgr install" 的 "--file" 参数来实现. 10 | 11 | 首先在能够联网的电脑上访问 12 | \href{https://ctan.org/tex-archive/systems/texlive/tlnet/archive}{\texttt{archive}} 13 | 页面, 下载 \texttt{.tar.xz} 文件. 14 | 文件列表很长, 加载需花费些时间. 15 | 注意 \texttt{} 未必是 16 | \href{https://ctan.org/pkg/}{\textsf{pkg}} 上的 \texttt{}, 17 | 例如在 \textsf{pkg} 上的 18 | \href{https://ctan.org/pkg/lshort-zh-cn}{\textsf{lshort-zh-cn}} 19 | 对应着 \texttt{archive} 上的 20 | \href{http://mirrors.ctan.org/systems/texlive/tlnet/archive/lshort-chinese.tar.xz}{\texttt{lshort-chinese.tar.xz}} 21 | 和 22 | \href{http://mirrors.ctan.org/systems/texlive/tlnet/archive/lshort-chinese.doc.tar.xz}{\texttt{lshort-chinese.doc.tar.xz}}. 23 | 24 | 这里多解释一点 \texttt{}. 25 | 前面已经看到一个 \texttt{} 可能会对应多个 \texttt{}, 26 | 但基本上 \texttt{} 的命名规则是 \texttt{}, 27 | \texttt{} 和 \texttt{}. 28 | \texttt{} 是必装的宏包文件; 29 | \texttt{} 是选择安装的源码, 如 \texttt{dtx} 文件; 30 | \texttt{} 是选择安装的文档, 如 \texttt{pdf} 文件等. 31 | 这三者未必同时存在, 例如前面提到的 \textsf{lshort-chinese}. 32 | 33 | 另外, 如果需要安装的是一个可执行文件, 例如 "pdftex" 或 "xetex", 34 | 那么会涉及到根据操作系统进行下载的相关判断. 35 | 如果要升级本地已安装的可执行文件, 可以在命令行输入以下语句查询: 36 | \begin{lstlisting}[title = \small\sffamily Windows 系统] 37 | tlmgr info --only-installed | findstr "pdftex" 38 | \end{lstlisting} 39 | %\begin{lstlisting}[title = {\small\sffamily Windows 系统}] 40 | % tlmgr info --only-installed | Select-String -Pattern 'pdftex' 41 | %\end{lstlisting} 42 | \begin{lstlisting}[title = \small\sffamily Ubuntu 和 macOS] 43 | tlmgr info --only-installed | grep 'pdftex' 44 | \end{lstlisting} 45 | 在输出结果中可看到带系统信息的名称. 46 | 如果是升级本地未安装的可执行文件, 47 | 那么用户就需要根据经验自行判断. 48 | 49 | 下载正确的 \texttt{.tar.xz} 后, 50 | 可先检查一下该压缩文件中是否包含了 \texttt{tlpobj} 文件. 51 | 之后将压缩文件拷贝到未联网电脑上, 52 | 在命令行执行 53 | \begin{lstlisting} 54 | tlmgr install --file .tar.gz 55 | \end{lstlisting} 56 | 系统便可自行安装. 57 | 58 | 对于部分提供了 "l3build" 脚本 \texttt{build.lua} 文件的宏包, 59 | 用户可在下载压缩文件后解压, 在解压后的目录中执行 60 | \begin{lstlisting} 61 | l3build install 62 | \end{lstlisting} 63 | 系统便可自行安装. 64 | -------------------------------------------------------------------------------- /chapter/overleaf.tex: -------------------------------------------------------------------------------- 1 | % !TeX root = ../install-latex-guide-zh-cn.tex 2 | 3 | \chapter{在线的 \LaTeX\ 平台} 4 | 5 | 在特定场合, 6 | 有些用户并不需要也没条件在本地安装发行版, 7 | 因此这里额外补充 \href{www.overleaf.com/}{Overleaf}, 8 | \href{https://www.texpage.com/}{TeXPage} 和 9 | \href{https://www.loongtex.com/}{LoongTeX} 的相关内容. 10 | 11 | \section{Overleaf} 12 | 13 | \subsection{注册 Overleaf} 14 | 15 | Overleaf 是全球范围内首屈一指的在线 \LaTeX\ 编辑平台. 16 | 它为每位用户提供了 Ubuntu 系统下的 \TeX~Live. 17 | 它优秀的协作功能、丰富的模板仓库已吸引全球科研工作者成为它的用户. 18 | Overleaf 提供了包括% 19 | \href{https://cn.overleaf.com/}{中文}% 20 | 在内的多种语言供用户使用. 21 | 2024年6月27日, 22 | \href{https://www.overleaf.com/blog/tex-live-2024-is-now-available}{它将后台的 \TeX~Live 升级为 2024 版本}, 23 | 同时, 24 | \href{https://www.overleaf.com/blog/new-feature-select-your-tex-live-compiler-version}{Overleaf 还允许用户自主选择项目中的 \TeX~Live 版本}. 25 | 26 | 目前 Overleaf 允许用户% 27 | \href{https://www.overleaf.com/learn/latex/Chinese}{使用中文}, 28 | 并为用户预先准备了一些% 29 | \href{https://www.overleaf.com/learn/latex/Questions/Which_OTF_or_TTF_fonts_are_supported_via_fontspec%3F#Fonts_for_CJK}{中文字体}. 30 | 这些中文字体可通过% 31 | \href{https://www.overleaf.com/latex/templates/using-the-ctex-package-on-overleaf-zai-overleafping-tai-shang-shi-yong-ctex/gndvpvsmjcqx}{C\TeX\ 宏集}% 32 | 调用. 33 | 特别推荐用户使用% 34 | \href{https://www.overleaf.com/latex/examples/demonstration-of-noto-serif-cjk-and-noto-sans-cjk-fonts/sgrwgcddtqsq}{思源宋体和思源黑体}% 35 | 这两种开源中文字体. 36 | 37 | 遗憾的是, 38 | 国内网络环境会对 Overleaf 所使用的 reCaptcha 造成影响. 39 | 这也使得很多用户在直接注册 Overleaf 时就遇到了问题. 40 | 41 | 目前, 42 | 比较好的替代方案是借助 \href{https://orcid.org/}{ORCID} 来进行注册. 43 | 目前使用国内网络访问 ORCID 还比较流畅. 44 | 用户, 尤其是科研工作者, 可以先注册一个 ORCID 账号. 45 | 未来投稿时, 46 | 可将 ORCID 账号与自己的期刊网站账号进行绑定. 47 | 同时, 48 | 用户也可逐步将自己所发表论文列在 ORCID 网站以便管理. 49 | 50 | \subsection{使用 Overleaf} 51 | 52 | 用户通过 ORCID 注册 Overleaf 后便可进入自己的项目列表页面进行使用. 53 | 54 | 新建项目是用户首先使用的功能. 55 | Overleaf 提供了多种渠道为用户新建项目: 56 | 可以通过 Overleaf 中的模板, 57 | 也可以通过上传本地的 \texttt{zip} 压缩文件包. 58 | 59 | 新建项目后, 60 | 用户便可进入编辑界面. 61 | 在编辑界面用户需要先在左上角 \menu{Menu} 中选择合适的编译命令. 62 | 由于默认字体和文件编码等原因, 63 | 强烈建议用户在处理中文文档时使用 \hologo{XeLaTeX}. 64 | 编写文档后, 65 | 用户可通过鼠标点击按钮进行编译, 66 | 也可使用快捷键 \keys{ctrl + enter}. 67 | 68 | 另外, 69 | Overleaf 在 2022 年 9 月 30 日更新了新的功能, 70 | \href{https://www.overleaf.com/blog/new-feature-stop-on-first-error-compilation-mode}{Stop on first error}, 71 | 这个功能一旦开启, 72 | 出现报错就立即停止编译. 73 | 它可以让用户高度关注报错信息并改正, 74 | 也可以帮助纠正一些会导致超时 (timeout) 的代码错误, 75 | 例如 Ti\textit kZ 里的 "\draw" 忘了最后的 ";". 76 | 77 | 用户编写的文件会保存在网站. 78 | 编写完成后, 79 | 用户只需点击 \menu{Menu} 旁的箭头回到项目列表. 80 | 这时可以看到新增项目右侧有四个图标, 81 | 它们分别是 \menu{Copy}、\menu{Download}、\menu{Archive} 和 \menu{Trash}. 82 | 用户可根据自己的需求点击合适的图标. 83 | 84 | \subsection{选择不同发行版版本} 85 | 86 | Overleaf 将后台 \TeX~Live 升级后, 87 | 用户新建项目默认使用 \TeX~Live 2024, 88 | 而老项目还是使用 \TeX~Live 的老版本. 89 | 如果用户不打算使用 \TeX~Live 2024, 90 | 只需在 \menu{Menu > Settings > TeX Live version} 选择版本即可. 91 | 92 | \subsection{学习与帮助} 93 | 94 | Overleaf 的% 95 | \href{https://www.overleaf.com/latex/templates}{模板}和% 96 | \href{https://www.overleaf.com/learn}{文档}% 97 | 对全网公开, 98 | 用户可以自行学习. 99 | 另外 Overleaf 有着专业的技术支援团队, 100 | 用户可发送邮件至 \href{mailto:support@overleaf.com}% 101 | {\texttt{support@overleaf.com}} 102 | 咨询使用过程中遇到的问题, 103 | 在邮件中请注意文明用语. 104 | 部分问题会超出免费服务的范畴, 105 | 用户需谨记这点. 106 | 107 | \section{TeXPage} 108 | 109 | \subsection{注册 TeXPage} 110 | 111 | TeXPage 是由国内公司开发的在线 \LaTeX\ 平台. 112 | 相较于 Overleaf 的注册困难, 113 | TeXPage 的注册则要方便得多. 114 | 用户只需访问它的主页, 115 | 使用邮箱注册即可, 116 | 具体过程不再赘述. 117 | 118 | \subsection{使用 TeXPage} 119 | 120 | 新用户注册 TeXPage 后会在页面看到一份使用教程. 121 | 这份教程简明扼要地概括了一般中文用户会遇到的常见问题, 122 | 然而从代码的角度而言, 123 | 我个人不欣赏在浮动体中使用 "H" 选项的做法. 124 | 125 | 在页面右上角的位置有许多菜单, 126 | 在\textsf{设置}菜单中, 127 | 用户可以选择默认的编译命令、发行版版本等等. 128 | 设置完毕, 129 | 再点击编译即可. 130 | 131 | \subsection{文档和帮助} 132 | 133 | TeXPage 有自己的 \href{https://www.texpage.com/docs}{文档中心}, 134 | 文档数量不多, 135 | 但涵盖了相当一部分基础知识. 136 | 同时, 137 | 它也提供了联系方式 \href{mailto:support@texpage.com}% 138 | {\texttt{support@texpage.com}}, 139 | 用户如果遇到了一些使用上的问题也可以直接发邮件咨询. 140 | 141 | \subsection{TeXPage 的优势} 142 | 143 | 在全球范围内, 144 | Overleaf 依然是在线 \LaTeX\ 平台的主流, 145 | 然而由于种种原因, 146 | 大陆地区用户体验不佳, 147 | 因此 TeXPage 就成为了一个稳定有效的新的选择. 148 | 149 | 目前在 TeXPage 上也具有一些颇具特色的模板, 150 | 例如建模比赛的一些模板就已经被收录在 TeXPage 当中. 151 | 如果未来 TeXPage 能够再尽可能收录大陆各个高校的毕业论文模板的话, 152 | 那可能是一件非常有趣的事情. 153 | 154 | \section{LoongTeX} 155 | 156 | \subsection{注册 LoongTeX} 157 | 158 | \href{https://www.loongtex.com/}{LoongTeX (龙文)} 159 | 是为科研人员打造的新一代 \LaTeX\ 工作平台, 160 | 集成了白板、类 Notion 笔记管理、异步协作和 AI 辅助功能, 助力高效完成论文与文档. 161 | 新用户可通过% 162 | \href{https://app.loongtex.com/user/login}{微信、谷歌账号或邮箱快速注册登录}, 163 | 即刻进入专属工作台界面. 164 | 165 | \subsection{使用 LoongTeX} 166 | 167 | LoongTeX 工作台提供「创建项目」「新建笔记」「发起白板」三类核心创作入口, 168 | 「创建项目」特别支持三种高效启动方式: 上传 \texttt{zip} 压缩包快速迁移本地 \LaTeX\ 工程、从% 169 | \href{https://www.loongtex.com/templates/}{超过 200 套毕业论文库}% 170 | 精准生成框架、或绑定 Git 仓库地址实现云端同步协作, 171 | 满足研究者从零开始创作、模板化写作到团队协同开发的全场景需求. 172 | 173 | 新建项目后, 系统自动进入三栏式编辑器页面: 左侧导航栏集成文件树管理(支持拖拽调整多级目录)、 174 | 可视化 Git 版本历史 (一键回溯任意版本) 及协作成员面板 (实时状态显示与异步留言); 175 | 中央编辑区搭载智能 \LaTeX\ 编辑器 (语法高亮/自动补全/实时纠错) 176 | 与分屏 PDF 预览 (注释联动定位); 177 | 右侧功能面板提供 AI 助手 (语法修正、术语优化) 178 | 和智能批注系统 (支持 Markdown 与公式嵌入的私有/团队注释), 179 | 形成「创作 --- 调试 --- 协作」一体化的沉浸式科研写作环境. 180 | 181 | \subsection{学习与帮助} 182 | 183 | 为保障科研用户的专注体验, LoongTeX 官网内嵌% 184 | \href{https://www.loongtex.com/docs/app/help/}{帮助中心}, 185 | 提供分场景的 \LaTeX\ 写作指南、异步协作操作手册及AI助手使用技巧 (含视频教程与学术案例). 186 | LoongTeX 提供专业技术支持, 用户可发送邮件至 187 | \href{mailto:loongtex@gmail.com}{\texttt{loongtex@gmail.com}} 188 | 咨询使用过程中遇到的问题. 189 | 190 | \subsection{LoongTeX 的优势} 191 | 192 | LoongTeX 针对科研场景深度优化, 相较 Overleaf 提供更专注的解决方案: 193 | 基于 Git 的异步协作避免实时同步对深度思考的干扰, 194 | 融合 Notion 式知识管理实现论文写作、数据整理与灵感记录的一站式操作, 195 | 内置 AI 学术助手精准优化语言表达与格式规范, 196 | 并通过贡献度追踪、双盲评审流程等机制满足科研协作的严谨性与合规性需求, 197 | 让复杂学术写作更专注高效. 198 | 199 | \section{其他在线平台} 200 | 201 | 除以上介绍的两个平台外, 202 | 大陆地区部分高校 (例如% 203 | \href{https://overleaf.tsinghua.edu.cn/login}{清华大学}% 204 | 和% 205 | \href{https://latex.ustc.edu.cn/login}{中国科学技术大学}) 也搭建了供内部师生使用的平台. 206 | 207 | 中国科学院计算机网络信息中心科技云运行与技术发展部曾发邮件宣称开始提供论文协同编辑服务, 208 | 据我猜测, 209 | 它利用了早年 Sharelatex 的部分内容. 210 | 试用可点击% 211 | \href{https://www.cstcloud.cn/resources/452}{这里}. 212 | 213 | 南京一家公司筹建了 214 | \href{https://www.slager.link/#/Home}{Slager} 在线 \LaTeX\ 编辑工具. 215 | 目前看来, 216 | Slager 的用法也比较简单, 217 | 并且有关于起步的% 218 | \href{https://www.slager.link/#/HelpCenter}{帮助文档}. 219 | 220 | \href{https://online.latexstudio.net/}{\LaTeX\ 工作室}也建立了一个在线平台, 221 | 这个平台目前只有一台服务器, 222 | 响应有点慢, 223 | 但是会免费供用户使用. 224 | -------------------------------------------------------------------------------- /chapter/preface.tex: -------------------------------------------------------------------------------- 1 | % !TeX root = ../install-latex-guide-zh-cn.tex 2 | 3 | \chapter*{前言} 4 | 5 | 以``啸行''名义加入 QQ 群 91940767、478023327、640633524 和 200392395 后, 6 | 经常有群友咨询如何安装 \LaTeX. 7 | 实际上, 8 | 用户安装的是 \LaTeX\ 的\textbf{发行版}和相关的\textbf{编辑器}. 9 | 本手册将介绍在\textbf{不存在其他 \LaTeX\ 发行版 (如 C\TeX\ 套装) 的前提下}, 10 | 在 Windows 11、Ubuntu 24.04 和 macOS 系统中安装 11 | \TeX~Live (macOS 中介绍 Mac\TeX)、升级宏包、编译简易文档等相关操作, 12 | 并多以介绍命令行操作为主. 13 | 有关 MiK\TeX\ 的安装, 14 | 可以参考 \href{https://camusecao.top/2021-06-16/MiKTeX/}{MiK\TeX\ 的基本使用}. 15 | 16 | 本手册还将简要介绍几款常见编辑器的使用方法, 17 | 其他编辑器如 \href{https://code.visualstudio.com/}{VS Code}, 18 | \href{https://www.vim.org/}{Vim}, 19 | 用户可自行了解它们的使用方法. 20 | 鉴于 WSL 较为特殊, 21 | 本手册提供了一份 VS Code 配合 22 | \href{https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop}{\LaTeX\ Workshop} 23 | 的自用配置单, 24 | 仅供参考. 25 | 26 | 除在本地安装 \LaTeX\ 发行版和编辑器之外, 27 | 本手册还额外补充三款在线的 \LaTeX\ 平台, 28 | 即 \href{http://www.overleaf.com/}{Overleaf}, 29 | \href{https://www.texpage.com/}{TeXPage} 和 30 | \href{https://www.loongtex.com/}{LoongTeX} 的相关内容. 31 | 32 | 本手册所涉及到的代码需结合上下文说明, 不能简单地复制粘贴. 33 | 粉色文字都是可点的超链接, 可直接跳转. 34 | \menu{菜单} 表示软件菜单. \keys{k} 表示键盘按键. 35 | 建议用户阅读 \href{https://tug.org/texlive/doc/texlive-zh-cn/texlive-zh-cn.pdf}{\textsf{texlive-zh-cn}} 36 | 和 \href{http://mirrors.ctan.org/info/lshort/chinese/lshort-zh-cn.pdf}{\textsf{lshort-zh-cn}} 37 | 以更全面地了解基础内容. 38 | 39 | 必须声明的是, 40 | 即便你已经通读本手册和上面提到的两本书, 41 | 有很大概率还会碰到很多问题. 42 | 这时我希望用户可以按照正确方式提问, 43 | 例如提供\textbf{最小工作示例}, 44 | 并在\href{https://ask.latexstudio.net/}{论坛}% 45 | 上面留下你的问题和相应解答以方便后来者. 46 | 47 | 本手册大部分内容是个人过去一段时间的使用总结, 其中难免有不甚合理或晦涩难懂的部分. 48 | 若用户在阅读本手册的过程中有任何意见和建议, 49 | 请发\href{mailto:ranwang.osbert@outlook.com}{邮件}或在 50 | \href{https://github.com/OsbertWang/install-latex-guide-zh-cn}{GitHub} 中提 51 | \href{https://github.com/OsbertWang/install-latex-guide-zh-cn/issues}{issue}. 52 | 本手册另在\href{https://gitee.com/OsbertWang/install-latex-guide-zh-cn}{码云}% 53 | 有备份, 54 | 并于 2020 年 7 月提交至 CTAN. 55 | 56 | 本手册发布后, 57 | \href{https://github.com/EthanDeng}{Dongsheng Deng}, 58 | \href{https://github.com/muzimuzhi}{muzimuzhi}, 59 | \href{https://github.com/stone-zeng}{Xiangdong Zeng}, 60 | \href{https://github.com/taumasyang}{tauyoung}, 61 | \href{https://github.com/myhsia}{myhsia}, 62 | 对本手册提出了很好的建议, 并提供了帮助, 63 | 其中, 有关 macOS 的内容最初由 Xiangdong Zeng 草拟完成, 64 | 而后 Dongsheng Deng, tauyoung 进行了补充, 65 | 最近一次更新则由 myhsia 提供. 66 | 在此一并感谢. 67 | 68 | 本手册自 2024 年 4 月开通捐赠渠道. 69 | 如果你认为本手册曾经帮助过你, 70 | 并且你还愿意继续支持本手册, 71 | 本着自愿原则, 72 | 你可以扫描以下二维码为本手册捐赠固定金额. 73 | 需要说明的是, 74 | 捐赠行为不会影响本手册的更新. 75 | 衷心感谢你的支持. 76 | 77 | \definecolor{alipay}{HTML}{1677FF} 78 | \definecolor{weixin}{HTML}{1AAD19} 79 | \begin{center} 80 | \fancyqr[ classic, height = 6em, color = black, version = 5, image = {\tikz 81 | \node [ inner sep = 0pt, rounded corners = .225em, 82 | draw, line width = .1em, alipay, 83 | minimum width = .95em, minimum height = .95em 84 | ] {\textcolor{alipay}\faAlipay};} 85 | ]{https://qr.alipay.com/fkx10265yq7niozotwocae3}% 86 | \qquad 87 | \fancyqr[ classic, height = 6em, color = black, version = 5, image = {\tikz 88 | \node [ inner sep = 0pt, rounded corners = .225em, 89 | fill = weixin, font = \footnotesize, 90 | minimum width = 1.05em, minimum height = 1.05em 91 | ] (wechat) {\textcolor{white}\faWeixin};} 92 | ]{wxp://f2f1ngYJgHLcAYkvo8VUlpSbF5_J5KiktdpOGmnA0ienTGgAgR2x20yWxEjzHWmIZfcT} 93 | \end{center} 94 | -------------------------------------------------------------------------------- /chapter/ubuntu.tex: -------------------------------------------------------------------------------- 1 | % !TeX root = ../install-latex-guide-zh-cn.tex 2 | 3 | \chapter{Ubuntu 24.04 系统} 4 | 5 | \section{安装 \TeX~Live}\label{chap:ubuntu:sec:install} 6 | 7 | 这里只阐述如何用镜像安装. 8 | 为使用户顺利使用 \TeX~Live 2025, 9 | 建议用户首先卸载从源内安装的 \TeX~Live 的相关包, 10 | 具体方法见 \ref{sec:ubuntu:uninstall}~节. 11 | 为了减少后续字体问题和文本编辑问题, 12 | 安装前在 \textsf{Terminal} 中执行 13 | \begin{lstlisting} 14 | sudo apt install fontconfig gedit 15 | \end{lstlisting} 16 | 由于大陆地区网络现状, 17 | 建议在执行命令前更换 Ubuntu 源, 18 | 参考 \ref{sec:addition:source}~节. 19 | 以下未特殊声明, 20 | 均指在 \textsf{Terminal} 中执行相关命令. 21 | 22 | 下载 23 | \href{https://mirrors.ctan.org/systems/texlive/Images/texlive2025.iso}{\texttt{iso} 镜像文件} 24 | 的方法见 \ref{sec:windows:install}~节. 25 | 下载完毕后, 26 | 验证 MD5 值, 27 | 即执行以下命令 28 | \begin{lstlisting} 29 | cd ~/Downloads 30 | md5sum texlive2025.iso 31 | \end{lstlisting} 32 | 若显示 33 | \begin{lstlisting} 34 | 69b4a8882983d9ea521730b5f42175e7 texlive2025.iso 35 | \end{lstlisting} 36 | 则镜像文件下载正确. 37 | 同样可验证 SHA512 值, 38 | 执行 39 | \begin{lstlisting} 40 | cd ~/Downloads 41 | sha512sum texlive2025.iso 42 | \end{lstlisting} 43 | 正确的返回结果为 44 | \begin{lstlisting}[literate={a}{a}{1} {b}{b}{1} {c}{c}{1} {d}{d}{1} {e}{e}{1} {f}{f}{1}] 45 | 1fd9a2234d086f50c832ab3ac8b83477bbc39b1138a3c4a2351244c1fd4b8bea6d1ac81d4a5b0cba95f2e82c00f0d9df5b33189eb222e4bae5dae1523ef0da0e texlive2025.iso 46 | \end{lstlisting} 47 | 48 | 将下载的光盘镜像进行装载 49 | \begin{lstlisting} 50 | sudo mkdir /mnt/texlive 51 | sudo mount ./texlive2025.iso /mnt/texlive 52 | \end{lstlisting} 53 | 接下来执行 54 | \begin{lstlisting} 55 | sudo /mnt/texlive/install-tl 56 | \end{lstlisting} 57 | 进行安装. 58 | 在屏幕上应该能见到以下内容 59 | \begin{lstlisting}[language = {}, deleteemph = set] 60 | ======================> TeX Live installation procedure <===================== 61 | 62 | ======> Letters/digits in indicate <======= 63 | ======> menu items for actions or customizations <======= 64 | = help> https://tug.org/texlive/doc/install-tl.html <======= 65 | 66 | Detected platform: GNU/Linux on x86_64 67 | 68 | set binary platforms: 1 out of 15 69 | 70 | set installation scheme: scheme-full 71 | 72 | set installation collections: 73 | 40 collections out of 41, disk space required: 8779 MB (free: 974100 MB) 74 | 75 | set directories: 76 | TEXDIR (the main TeX directory): 77 | /usr/local/texlive/2025 78 | TEXMFLOCAL (directory for site-wide local files): 79 | /usr/local/texlive/texmf-local 80 | TEXMFSYSVAR (directory for variable and automatically generated data): 81 | /usr/local/texlive/2025/texmf-var 82 | TEXMFSYSCONFIG (directory for local config): 83 | /usr/local/texlive/2025/texmf-config 84 | TEXMFVAR (personal directory for variable and automatically generated data): 85 | ~/.texlive2025/texmf-var 86 | TEXMFCONFIG (personal directory for local config): 87 | ~/.texlive2025/texmf-config 88 | TEXMFHOME (directory for user-specific files): 89 | ~/texmf 90 | 91 | options: 92 | [ ] use letter size instead of A4 by default 93 | [X] allow execution of restricted list of programs via \write18 94 | [X] create all format files 95 | [X] install macro/font doc tree 96 | [X] install macro/font source tree 97 | [ ] create symlinks to standard directories 98 | [X] after install, set CTAN as source for package updates 99 | 100 | set up for portable installation 101 | 102 | Actions: 103 | start installation to hard disk 104 |

save installation profile to 'texlive.profile' and exit 105 | quit 106 | 107 | Enter command: 108 | \end{lstlisting} 109 | 点击键盘 \keys{I} 进行默认安装. 110 | 如果用户对于 Ubuntu 系统比较了解, 111 | 可以根据提示, 112 | 更改安装设置, 113 | 如安装路径等. 114 | 为简化起见, 115 | 以下记录均假定为 \path{x86_64} 上的默认安装. 116 | 安装完毕后, 117 | 系统会提示用户添加环境变量, 118 | 例如 119 | \begin{lstlisting}[deletekeywords = local] 120 | export PATH=/usr/local/texlive/2025/bin/x86_64-linux:$PATH 121 | export MANPATH=/usr/local/texlive/2025/texmf-dist/doc/man:$MANPATH 122 | export INFOPATH=/usr/local/texlive/2025/texmf-dist/doc/info:$INFOPATH 123 | \end{lstlisting} 124 | 不同操作系统此处显示略有不同, 125 | 用户需将此处的系统提示记录. 126 | 127 | 将装载的光盘镜像弹出并删除文件夹, 128 | 即执行 129 | \begin{lstlisting} 130 | sudo umount /mnt/texlive 131 | sudo rm -r /mnt/texlive 132 | \end{lstlisting} 133 | 134 | 设置环境变量. 135 | 执行 136 | \begin{lstlisting} 137 | gedit ~/.profile 138 | \end{lstlisting} 139 | 在打开的文件末尾添加刚刚记录的系统提示, 140 | 如 141 | \begin{lstlisting}[deletekeywords = local] 142 | # Add TeX Live to the PATH, MANPATH, INFOPATH 143 | export PATH=/usr/local/texlive/2025/bin/x86_64-linux:$PATH 144 | export MANPATH=/usr/local/texlive/2025/texmf-dist/doc/man:$MANPATH 145 | export INFOPATH=/usr/local/texlive/2025/texmf-dist/doc/info:$INFOPATH 146 | \end{lstlisting} 147 | 并保存退出. 148 | 然后退出当前用户并重新登录, 149 | 再打开 \textsf{Terminal} 并执行 150 | \begin{lstlisting} 151 | tex -v 152 | \end{lstlisting} 153 | 若显示 154 | \begin{lstlisting}[language = {}] 155 | TeX 3.141592653 (TeX Live 2025) 156 | kpathsea version 6.4.1 157 | Copyright 2025 D.E. Knuth. 158 | There is NO warranty. Redistribution of this software is 159 | covered by the terms of both the TeX copyright and 160 | the Lesser GNU General Public License. 161 | For more information about these matters, see the file 162 | named COPYING and the TeX source. 163 | Primary author of TeX: D.E. Knuth. 164 | \end{lstlisting} 165 | 即为安装成功. 166 | 167 | 接下来处理字体. 168 | 在 \textsf{Terminal} 中执行 169 | \begin{lstlisting}[deletekeywords = local] 170 | sudo cp /usr/local/texlive/2025/texmf-var/fonts/conf/texlive-fontconfig.conf /etc/fonts/conf.d/09-texlive.conf 171 | \end{lstlisting} 172 | 将配置文件复制到系统, 173 | 然后继续执行 174 | \begin{lstlisting} 175 | sudo fc-cache -fsv 176 | \end{lstlisting} 177 | 刷新字体缓存. 178 | 这样一来, \TeX~Live 中的字体才能够被正确调用. 179 | 更多内容请参考 \href{https://tug.org/texlive/doc/texlive-zh-cn/texlive-zh-cn.pdf}{\textsf{texlive-zh-cn}}. 180 | 181 | 如果用户更改了安装路径, 182 | 要注意将 183 | \begin{lstlisting}[language = {}] 184 | /usr/local/texlive/2025/ 185 | \end{lstlisting} 186 | 在各处替换. 187 | 188 | \subsection{在用户文件夹安装}\label{subsec:ubuntu-user-folder} 189 | 190 | 如果有用户打算在用户文件夹安装 \TeX~Live, 191 | 那么可以不必调用权限, 192 | 直接执行 193 | \begin{lstlisting} 194 | /mnt/texlive/install-tl 195 | \end{lstlisting} 196 | 只不过这时安装路径需要选择 197 | \begin{lstlisting} 198 | ~/texlive/2025 199 | \end{lstlisting} 200 | 安装完毕后, 201 | 继续修改环境变量为 202 | \begin{lstlisting} 203 | # Add TeX Live to the PATH, MANPATH, INFOPATH 204 | export PATH=~/texlive/2025/bin/x86_64-linux:$PATH 205 | export MANPATH=~/texlive/2025/texmf-dist/doc/man:$MANPATH 206 | export INFOPATH=~/texlive/2025/texmf-dist/doc/info:$INFOPATH 207 | \end{lstlisting} 208 | 有关字体的处理变为% 209 | \footnote{这里并未使用 210 | \href{https://tug.org/texlive/doc/texlive-zh-cn/texlive-zh-cn.pdf}{\textsf{texlive-zh-cn}} 211 | 中建议的路径 \path{~/.fonts.conf.d/}, 212 | 因为根据 \href{https://www.freedesktop.org/software/fontconfig/fontconfig-user.html}{freedesktop} 的说法, 213 | 该路径已废弃, 214 | 故此处采用新的路径, 215 | 即 \path{$XDG_CONFIG_HOME/fontconfig/conf.d/}} 216 | \begin{lstlisting} 217 | cp ~/texlive/2025/texmf-var/fonts/conf/texlive-fontconfig.conf $XDG_CONFIG_HOME/fontconfig/conf.d/09-texlive.conf 218 | \end{lstlisting} 219 | 然后执行 220 | \begin{lstlisting} 221 | fc-cache -fv 222 | \end{lstlisting} 223 | 实际上, 224 | 无论将 \TeX~Live 安装到哪里, 225 | 字体的配置文件都可以仿照上面只复制于用户文件夹中. 226 | 227 | \section{升级宏包}\label{sec:ubuntu:update} 228 | 229 | 首次升级前, 230 | 在 \textsf{Terminal} 中执行 231 | \begin{lstlisting} 232 | sudo visudo 233 | \end{lstlisting} 234 | 将 235 | \begin{lstlisting}[language = {}] 236 | /usr/local/texlive/2025/bin/x86_64-linux: 237 | \end{lstlisting} 238 | 添加在 \path{secure_path} 中% 239 | \footnote{这里只讨论 \path{x86_64} 下默认安装的情况, 240 | 若用户设备的处理器是基于 \texttt{arm64} 架构的, 241 | 则需要将 \path{x86_64-linux} 替换为 \path{aarch64-linux}}. 242 | 然后依次 \keys{\ctrl + X}, \keys{Y}, \keys{\enter} 保存退出. 243 | 244 | 接下来在 \textsf{Terminal} 中执行 245 | \begin{lstlisting} 246 | sudo tlmgr option repository ctan 247 | \end{lstlisting} 248 | 让系统自动选择源, 249 | 同样可以使用大陆地区的源升级, 250 | 详情见附录~\ref{chp:appendix:mirror}. 251 | 执行命令 252 | \begin{lstlisting} 253 | sudo tlmgr update --list 254 | \end{lstlisting} 255 | 可查看目前源上可升级的宏包都有哪些. 256 | 高级用户可以根据自己的需求选择升级特定宏包. 257 | 建议初级用户执行 258 | \begin{lstlisting} 259 | sudo tlmgr update --self --all 260 | \end{lstlisting} 261 | 同时升级 "tlmgr" 本身和全部宏包. 262 | 263 | \section{安装宏包}\label{sec:ubuntu:installpackage} 264 | 265 | Ubuntu 24.04 下安装宏包的要求与 Windows 11 下没有多少区别, 只需注意权限, 例如 266 | \begin{lstlisting} 267 | sudo tlmgr install mcmthesis 268 | \end{lstlisting} 269 | 即安装了 \texttt{mcmthesis} 宏包. 270 | 271 | \section{调出宏包手册}\label{sec:ubuntu:texdoc} 272 | 273 | 与 Windows 11 类似, 274 | 当正确安装后, 275 | 用户可以调出宏包手册以查阅相应内容. 276 | 例如在 \textsf{Terminal} 中执行 277 | \begin{lstlisting} 278 | texdoc texlive-zh-cn 279 | texdoc lshort-zh-cn 280 | texdoc install-latex-guide-zh-cn 281 | \end{lstlisting} 282 | 就可分别调出 \texttt{texlive-zh-cn.pdf}, 283 | \texttt{lshort-zh-cn.pdf} 284 | 或本手册. 285 | 286 | \section{编译文件} 287 | 288 | 首先, 用户需要在工作路径建立一个 \texttt{tex} 文件. 289 | 在 \textsf{Terminal} 中执行 290 | \begin{lstlisting}[deletekeywords = tex] 291 | mkdir ~/Documents/work-latex 292 | cd ~/Documents/work-latex/ 293 | gedit main.tex 294 | \end{lstlisting} 295 | 在打开的文件输入一个最小示例 296 | \begin{lstlisting}[language = mwe] 297 | \documentclass{article} 298 | \begin{document} 299 | Hello \LaTeX\ World! 300 | \end{document} 301 | \end{lstlisting} 302 | 保存并退出. 303 | 接下来执行 304 | \begin{lstlisting} 305 | pdflatex main 306 | \end{lstlisting} 307 | 等待系统完成编译过程. 308 | 待编译完成后, 309 | 我们即可看到在 \path{~/Documents/work-latex/} 中出现了 310 | \texttt{main.pdf} 文件和其他同名的辅助文件 \texttt{main.aux} 与 311 | \texttt{main.log}. 312 | 执行 313 | \begin{lstlisting} 314 | evince main.pdf 315 | \end{lstlisting} 316 | 即可打开 \texttt{pdf} 文件. 317 | 318 | 对于中文文档, 可以在 "gedit" 中编写以下最小示例\footnote{gedit 默认使用 UTF-8 编码}% 319 | \begin{lstlisting}[language = mwe] 320 | \documentclass[fontset = fandol]{ctexart} 321 | \begin{document} 322 | 你好 \LaTeX\ 世界! 323 | \end{document} 324 | \end{lstlisting} 325 | 保存并退出. 326 | 接下来执行 327 | \begin{lstlisting} 328 | xelatex main 329 | \end{lstlisting} 330 | 等待系统完成编译过程. 331 | "xelatex" 可以使用系统内安装的字体, 332 | 安装字体的方法可参考 \ref{sec:addition:font}~节. 333 | 334 | 编译命令可添加参数, 这里与 \ref{sec:windows:compile}~节中的情形一致. 335 | 336 | \section{卸载 \TeX~Live}\label{sec:ubuntu:uninstall} 337 | 338 | 下面提供几种卸载方法, 339 | 卸载后需注意清理环境变量. 340 | 341 | \subsection{卸载源内的版本}\label{sec:ubuntu:aptremove} 342 | 343 | 如果要卸载从源内安装的 \TeX~Live, 个人比较推荐使用 \texttt{synaptic package manager}. 344 | 在 \textsf{Terminal} 中执行 345 | \begin{lstlisting} 346 | sudo apt install synaptic 347 | \end{lstlisting} 348 | 即可安装. 349 | 安装后打开, 搜索 \textsf{texlive} 即可看到与之相关的包, 右键标记以删除即可. 350 | 当然, 用户也可以直接使用 351 | \begin{lstlisting} 352 | dpkg -l | grep 'TeX Live' 353 | \end{lstlisting} 354 | 找到相应的包名 \texttt{}, 之后使用类似 355 | \begin{lstlisting} 356 | sudo apt autoremove --purge 357 | \end{lstlisting} 358 | 的命令删除各个包. 359 | 通常 360 | \begin{lstlisting} 361 | sudo apt autoremove --purge tex-common 362 | \end{lstlisting} 363 | 就可以删除源内版本. 364 | 365 | \subsection{手动卸载} 366 | 367 | 如果是从光盘镜像安装, 368 | 直接删除文件夹即可. 369 | 先在\textsf{Terminal} 中执行 370 | \begin{lstlisting} 371 | kpsewhich -var-value TEXMFROOT 372 | \end{lstlisting} 373 | 来查询安装路径, 374 | 进而通过 "sudo rm -rf" 命令进行删除. 375 | 默认安装的用户直接运行 376 | \begin{lstlisting}[deletekeywords = local] 377 | sudo rm -rf /usr/local/texlive/2025 378 | rm -rf ~/.texlive2025 379 | \end{lstlisting} 380 | 卸载完成后, 可以进一步移除之前设置的环境变量. 381 | 在 \textsf{Terminal} 中执行 382 | \begin{lstlisting} 383 | gedit ~/.profile 384 | \end{lstlisting} 385 | 然后移除之前在文件末尾添加的 386 | \begin{lstlisting}[deletekeywords = local] 387 | # Add TeX Live to the PATH, MANPATH, INFOPATH 388 | export PATH=/usr/local/texlive/2025/bin/x86_64-linux:$PATH 389 | export MANPATH=/usr/local/texlive/2025/texmf-dist/doc/man:$MANPATH 390 | export INFOPATH=/usr/local/texlive/2025/texmf-dist/doc/info:$INFOPATH 391 | \end{lstlisting} 392 | 并保存退出. 393 | 同时在 \textsf{Terminal} 中执行 394 | \begin{lstlisting} 395 | sudo visudo 396 | \end{lstlisting} 397 | 在 \path{secure_path} 中删除 398 | \begin{lstlisting}[deletekeywords = local] 399 | /usr/local/texlive/2025/bin/x86_64-linux: 400 | \end{lstlisting} 401 | 然后依次 \keys{\ctrl + X}, \keys{Y}, \keys{\enter} 保存退出. 402 | 403 | \subsection{使用 \texttt{tlmgr} 工具} 404 | 405 | 同样, 406 | 用户也可以使用 "tlmgr" 工具卸载% 407 | \footnote{"sudo tlmgr" 无法使用的情况可以参考 \ref{sec:ubuntu:update}~节 解决}, 408 | \begin{lstlisting} 409 | sudo tlmgr remove --all 410 | \end{lstlisting} 411 | 412 | \section{跨版本升级 \TeX~Live}\label{sec:ubuntu:version} 413 | 414 | 在 \href{https://www.tug.org/texlive/upgrade.html}{\texttt{tug.org}} 415 | 网站上提供了相应的方法. 416 | 但网站也声明: 417 | 默认情况下, 418 | 请通过执行新安装来获取新版本的 \TeX~Live% 419 | \footnote{原文是: By default, 420 | please get the new TL by doing a new installation instead of proceeding here}. 421 | -------------------------------------------------------------------------------- /chapter/updateinfo.tex: -------------------------------------------------------------------------------- 1 | % !TeX root = ../install-latex-guide-zh-cn.tex 2 | 3 | \twocolumn 4 | 5 | \chapter{版本信息} 6 | 7 | \section*{v2025.6.1} 8 | 9 | \begin{itemize} 10 | \item 更正 macOS 中通过 Homebrew 安装 \TeX studio 的命令 11 | \item 订正拼写细节错误 12 | \item 更新一处失效的博客链接 13 | \item 更新 \texttt{build.lua} 14 | \item 增加联合高校镜像源说明以及地址 15 | \end{itemize} 16 | 17 | \section*{v2025.5.1} 18 | 19 | \begin{itemize} 20 | \item 添加了 Homebrew 的快速安装脚本 21 | \item 更改了手册的代码高亮样式 22 | \item 订正拼写细节错误 23 | \end{itemize} 24 | 25 | \section*{v2025.4.1} 26 | 27 | \begin{itemize} 28 | \item 更正 WSL 中的错误 29 | \item 添加山东大学镜像 30 | \item 解释 Mac\TeX\ 字体问题 31 | \item 增加 \texttt{Cygwin} 的提示 32 | \item 增加 Mac\TeX\ 命令行卸载相关内容 33 | \item 删除了示例中的 \texttt{UTF8} 选项 34 | \item 给出 \texttt{build.lua} 35 | \item 更新商用编辑器的最新价格 36 | \item 添加了 "l3build" 的离线安装方式 37 | \item 调整大陆镜像地址 38 | \item 新增 LoongTeX 在线平台 39 | \item 更新捐赠二维码 40 | \end{itemize} 41 | 42 | \section*{v2025.3.10} 43 | 44 | \begin{itemize} 45 | \item 更新 \TeX~Live 2025 46 | \end{itemize} 47 | 48 | \section*{v2025.3.1} 49 | 50 | \begin{itemize} 51 | \item 增加了开启 \textsf{cmd} 界面的介绍 52 | \end{itemize} 53 | 54 | \section*{v2025.1.1} 55 | 56 | \begin{itemize} 57 | \item 强调了记录 Ubuntu 安装时用的 \texttt{x86\_64} 58 | \item 将卸载和跨版本升级内容调整至章末 59 | \item 增加 \TeX Studio PDF 阅读器内容 60 | \end{itemize} 61 | 62 | \section*{v2024.9.1} 63 | 64 | \begin{itemize} 65 | \item Overleaf 升级为 2024 版 66 | \end{itemize} 67 | 68 | \section*{v2024.6.1} 69 | 70 | \begin{itemize} 71 | \item 添加镜像 72 | \item 修改对于不安装第三方安全软件的建议 73 | \end{itemize} 74 | 75 | \section*{v2024.4.1} 76 | 77 | \begin{itemize} 78 | \item 添加 \TeX studio 的 AppImage 内容 79 | \item 调整编辑器售价 80 | \item 调整大陆镜像地址 81 | \item 增加捐赠渠道 82 | \end{itemize} 83 | 84 | \section*{v2024.3.15} 85 | 86 | \begin{itemize} 87 | \item 更新 \TeX~Live 2024 88 | \end{itemize} 89 | 90 | \section*{v2024.1.1} 91 | 92 | \begin{itemize} 93 | \item 订正前言超链接 94 | \end{itemize} 95 | 96 | \section*{v2023.12.1} 97 | 98 | \begin{itemize} 99 | \item 订正 Ubuntu 系统下环境变量生效的内容 100 | \item 修订 Windows 中文用户名的一处年份错误 101 | \end{itemize} 102 | 103 | \section*{v2023.11.1} 104 | 105 | \begin{itemize} 106 | \item 更新 MacTeX 安装内容 (感谢 \href{https://github.com/tauyoungsama}{tauyoung} 起草) 107 | \end{itemize} 108 | 109 | \section*{v2023.10.1} 110 | 111 | \begin{itemize} 112 | \item Overleaf 升级为 2023 版 113 | \end{itemize} 114 | 115 | \section*{v2023.9.1} 116 | 117 | \begin{itemize} 118 | \item Ubuntu 下 fontconfig 路径问题 119 | \end{itemize} 120 | 121 | \section*{v2023.7.1} 122 | 123 | \begin{itemize} 124 | \item 补充在线平台 125 | \end{itemize} 126 | 127 | \section*{v2023.6.1} 128 | 129 | \begin{itemize} 130 | \item 在 PDF 书签中显示章节序号 131 | \end{itemize} 132 | 133 | \section*{v2023.5.1} 134 | 135 | \begin{itemize} 136 | \item 更新 Ubuntu 环境变量和字体安装 137 | \item 添加 TUG 的编辑器列表 138 | \end{itemize} 139 | 140 | \section*{v2023.4.1} 141 | 142 | \begin{itemize} 143 | \item 重构有关 Ubuntu 和 WSL 的内容 144 | \item 补北京大学和华为云镜像 145 | \item 订正 Windows 系统下安装目录的错误 146 | \end{itemize} 147 | 148 | \section*{v2023.3.23} 149 | 150 | \begin{itemize} 151 | \item 更新 \TeX~Live 2023 相关内容 152 | \item 更改有关编辑器的内容 153 | \item 添加一些可以直接用包管理器安装字体的信息 154 | \end{itemize} 155 | 156 | \section*{v2023.1.1} 157 | 158 | \begin{itemize} 159 | \item 订正拼写细节错误 160 | \item 更新大陆可用源列表 161 | \item 更新有关 \TeX studio 部分设置 162 | \end{itemize} 163 | 164 | \section*{v2022.10.1} 165 | 166 | \begin{itemize} 167 | \item Overleaf 添加 Stop on first error 功能 168 | \end{itemize} 169 | 170 | \section*{v2022.9.1} 171 | 172 | \begin{itemize} 173 | \item Overleaf 升级至 \TeX~Live 2022 174 | \end{itemize} 175 | 176 | \section*{v2022.8.1} 177 | 178 | \begin{itemize} 179 | \item 补充 Mac\TeX\ 卸载和跨版本升级的一些内容 180 | \item 添加了一个编译参数的例子 181 | \item 删除了失效的国内镜像 182 | \end{itemize} 183 | 184 | \section*{v2022.7.1} 185 | 186 | \begin{itemize} 187 | \item 补充 TeXPage 相关内容 188 | \end{itemize} 189 | 190 | \section*{v2022.5.1} 191 | 192 | \begin{itemize} 193 | \item Windows、Ubuntu 和 WSL 下安装 \TeX~Live 2022 的内容更新 194 | \item 统一挂载、加载为装载, 与现行 Windows 系统名称统一 195 | \end{itemize} 196 | 197 | \section*{v2022.4.1} 198 | 199 | \begin{itemize} 200 | \item 根据 Dongsheng Deng 提供的内容, 修改 macOS 安装文本 201 | \end{itemize} 202 | 203 | \section*{v2022.3.1} 204 | 205 | \begin{itemize} 206 | \item 更改 \TeX works 的编译命令设置 207 | \end{itemize} 208 | 209 | \section*{v2021.12.1} 210 | 211 | \begin{itemize} 212 | \item \TeX studio Qt6 版本在 Windows 系统上存在问题 213 | \end{itemize} 214 | 215 | \section*{v2021.11.1} 216 | 217 | \begin{itemize} 218 | \item Overleaf 升级为 \TeX~Live 2021 219 | \end{itemize} 220 | 221 | \section*{v2021.10.1} 222 | 223 | \begin{itemize} 224 | \item 添加 ubuntu 和 WSL 在用户文件夹安装的相关内容 225 | \end{itemize} 226 | 227 | \section*{v2021.8.1} 228 | 229 | \begin{itemize} 230 | \item 改动一些文本上的小问题 231 | \item 改动错误的链接 232 | \item 添加南方科技大学镜像 233 | \item 添加 Windows 10 系统内注册表位置 234 | \end{itemize} 235 | 236 | \section*{v2021.7.3} 237 | 238 | \begin{itemize} 239 | \item 添加 Windows 中文用户名处理方法的提示 240 | \item 添加 \TeX works 拼写检查文件夹建立的提示 241 | \end{itemize} 242 | 243 | \section*{v2021.5.1} 244 | 245 | \begin{itemize} 246 | \item 添加 Windows 中文用户名导致安装失败的解决方法 247 | \item 添加升级宏包的必要性 248 | \item 更正两处超链接 249 | \end{itemize} 250 | 251 | \section*{v2021.4.7} 252 | 253 | \begin{itemize} 254 | \item 更新安装 \TeX~Live 2021 内容 255 | \item 添加东莞理工学院源 256 | \item 补充 \TeX studio 下载方法 257 | \item 补充 WSL 中使用 "texdoc" 的方法 258 | \end{itemize} 259 | 260 | \section*{v2021.2.1} 261 | 262 | \begin{itemize} 263 | \item 更新 \texttt{l3backend-*} 解决方案 264 | \item 补充调整安装路径后的操作 265 | \item 调整大陆镜像地址 266 | \end{itemize} 267 | \section*{v2020.12.1} 268 | 269 | \begin{itemize} 270 | \item 更新哈工大源 271 | \item 添加 CTAN 镜像列表和连接情况网址 272 | \item 调整 Ubuntu 和 WSL 字体相关内容 273 | \end{itemize} 274 | 275 | \section*{v2020.11.1} 276 | 277 | \begin{itemize} 278 | \item Overleaf 后台更新为 \TeX~Live 2020 279 | \item 补充卸载方法 280 | \item 补充 PPA 反向代理安装 \TeX Studio 的方法 281 | \end{itemize} 282 | 283 | \section*{v2020.10.1} 284 | 285 | \begin{itemize} 286 | \item 增加北京外国语大学镜像链接 287 | \item 修正 Windows 10 中用 "sudo" 命令的错误 288 | \item 完善 Windows 下手动删除涉及的注册表位置 289 | \end{itemize} 290 | 291 | \section*{v2020.8.2} 292 | 293 | \begin{itemize} 294 | \item 增加验证 sha512 的内容 295 | \item 将本文提交至 CTAN 而进行必要更改 296 | \item 利用 "texdoc" 调出本手册 297 | \item 给出直接下载 Mac\TeX\ 的链接 298 | \end{itemize} 299 | 300 | \section*{v2020.7.1} 301 | 302 | \begin{itemize} 303 | \item \TeX works 拼写检查调整 304 | \item VS Code 是开源软件 305 | \item 改摘要为前言并增加内容 306 | \item 增加调出宏包手册内容 307 | \end{itemize} 308 | 309 | \section*{v2020.6.1} 310 | 311 | \begin{itemize} 312 | \item 重述大陆地区的源的相关内容 313 | \item 为适应 Ubuntu 20.04 调整某些内容 314 | \item 调整有关管理员权限的内容 315 | \item 调整有关编辑器的内容 316 | \item 借助网站加速下载 TeXstudio 317 | \item 提示卸载时的权限 318 | \item 给出 \texttt{make.bat} 与 \texttt{makefile} 319 | \item 增加 MD5 的说明 320 | \item 更正设置主文档的错误 321 | \end{itemize} 322 | 323 | \section*{v2020.5.1} 324 | 325 | \begin{itemize} 326 | \item 更新 MiK\TeX\ 相关网址 327 | \item 更新 至 \TeX~Live 2020 328 | \item 更新 Windows 10 手动卸载 \TeX~Live 的内容 329 | \item 调整 \TeX studio 图标大小 330 | \item 更新镜像网址 331 | \item 更改 \textsf{OpenOffice} 网址 332 | \item 更新 Windows 10 升级宏包描述 333 | \item 更新 Overleaf 的介绍 334 | \end{itemize} 335 | 336 | \section*{v2020.4.1} 337 | 338 | \begin{itemize} 339 | \item 简要介绍 WSL 辅助程序 340 | \item 添加 Overleaf 学习与帮助 341 | \item 添加两处与 WSL 有关的内容 342 | \item 增加几处软件菜单栏的讲解 343 | \item 更清晰查看 Windows 10 环境变量的代码 344 | \item Windows 10 直接以管理员身份打开命令行安装 345 | \item 调整标点 346 | \end{itemize} 347 | 348 | \section*{v2020.3.1} 349 | 350 | \begin{itemize} 351 | \item 摘要中明确提到 C\TeX\ 套装和发行版、编辑器 352 | \item 更改 Windows 10 安装 \TeX~Live 的描述, 如路径名, 文件扩展名等 353 | \item 将文件名要求写入注释 354 | \item 添加 \TeX studio 数学符号表和插入、改写调整 355 | \item 解决 \LaTeXe\ 版本不匹配导致 "xelatex" 失败的问题 356 | \item 添加打开 \textsf{cmd} 的方法 357 | \item 改写 \TeX studio 显示行号的设置 358 | \item 更新 MiK\TeX\ 相关网址 359 | \item 添加调整 \TeX works 字体的内容 360 | \item 添加 Windows 中手动卸载 \TeX~Live 的方法 361 | \item 添加 Overleaf 中文网址 362 | \end{itemize} 363 | 364 | \section*{v2020.2.1} 365 | 366 | \begin{itemize} 367 | \item 添加版本信息列表 368 | \item 改变 Windows 10 的 \TeX studio 的下载网址 369 | \item 添加 macOS 中 "xelatex" 用字体名调用字体的方法 370 | \item 详述 WSL 中不懂 \textsf{vim} 的处理方法和阅读宏包手册的方法 371 | \item 强调路径为不带空格的英文 372 | \item 订正若干拼写错误 373 | \item 给出 \texttt{jdk} 环境变量的处理 374 | \item 添加北京交通大学镜像 375 | \item 注明安装需卸载国产安全软件 376 | \item 更正 \TeX works 自动补全的教程网址 377 | \item 给出更换 2345 好压的建议 378 | \item 补充 Overleaf 升级内容 379 | \end{itemize} 380 | -------------------------------------------------------------------------------- /chapter/windows.tex: -------------------------------------------------------------------------------- 1 | % !TeX root = ../install-latex-guide-zh-cn.tex 2 | 3 | \chapter{Windows 11 系统} 4 | 5 | \section{安装 \TeX~Live}\label{sec:windows:install} 6 | 7 | 在安装 \TeX~Live 之前, 8 | 在文件夹菜单栏 \menu{查看 > 显示} 中选择 \menu{文件扩展名}. 9 | 10 | 用户可以从最近的 CTAN 源% 11 | \footnote{这里所谓的最近, 其实是由系统判定的, 实际上系统可能会误判}% 12 | 下载 \TeX~Live 的 13 | \href{https://mirrors.ctan.org/systems/texlive/Images/texlive2025.iso}{\texttt{iso} 镜像文件}, 14 | 也可以找大陆地区的源自行下载\footnote{新版本发布时, 各镜像网站同步的进度会有不同}. 15 | 通过大陆地区的源下载 \texttt{iso} 文件的方法请参考附录~\ref{chp:appendix:mirror}. 16 | 17 | 假设镜像文件被下载到本地后, 18 | 其存放路径为 \path{X:\Y}% 19 | \footnote{这里, \path{X} 表示盘符, 20 | 如 \path{C}、\path{D}、\path{E} 等; 21 | \path{Y} 表示文件夹; 22 | 默认路径名称为不带空格的英文}. 23 | 下载完毕后, 用户打开 \textsf{cmd} 窗口% 24 | \footnote{按 \keys{\faWindows}, 25 | 或在任意文件夹中按 \keys{\ctrl + L}, 26 | 输入 \textsf{cmd}, 27 | 点击 \keys{\enter}}, 28 | 将会见到诸如以下内容 29 | \begin{lstlisting} 30 | C:\Users\username> 31 | \end{lstlisting} 32 | %\begin{lstlisting} 33 | % PS C:\Users\username> 34 | %\end{lstlisting} 35 | 它显示了当前所在路径并等待用户下一步操作, 36 | 通常在开启 \textsf{cmd} 或上一程序运行结束时会显示. 37 | 38 | 在 \textsf{cmd} 执行 39 | \begin{lstlisting} 40 | echo %path:;=&echo.% 41 | \end{lstlisting} 42 | %\begin{lstlisting} 43 | % $env:Path -split ';' 44 | %\end{lstlisting} 45 | 查看环境变量. 46 | 若 \path{C:\Windows\system32} 47 | 不在结果中\footnote{这里默认系统盘为 \path{C} 盘}, 48 | 则关闭 \textsf{cmd} 窗口, 49 | 将 \path{C:\Windows\system32} 50 | 添加到环境变量中% 51 | \footnote{在 \menu{桌面 > 此电脑 > 属性 > 高级系统设置 > 环境变量 > 系统变量 > Path} 中添加}. 52 | \textbf{根据以往经验, 安装老版 C\TeX\ 套装的用户往往会有} 53 | \path{system32} \textbf{丢失的问题}. 54 | 55 | 另外, 如果环境变量中有 \texttt{mingw}、\texttt{jdk}、\texttt{Cygwin} 相关的内容, 56 | 也请暂时删除% 57 | \footnote{前两者具体原因参见 58 | \href{https://tex.stackexchange.com/questions/445086/error-installing-latest-version-of-tex-live-on-windows-10}{\textsf{Stack\textbf{Exchange}}} 59 | 的解释, 待安装结束后, 再将环境变量重新添加至 \TeX~Live 的环境变量之后}. 60 | 同时国内常见的 2345 好压也会对安装构成影响, 61 | 建议删除它并在安装 \TeX~Live 后更换其他同类软件% 62 | \footnote{推荐 \href{http://www.winrar.com.cn/}{WinRAR} 63 | 或 \href{https://www.7-zip.org/}{7-Zip}}. 64 | \textbf{最重要的是, 不要安装第三方安全软件}% 65 | \footnote{Windows 11 中已经内置了安全软件, 66 | 用户尤其没有必要安装国产的第三方杀毒软件, 67 | 根据经验, 68 | 它们会干扰 \TeX~Live 安装}. 69 | 70 | 下面我们要确保下载到的 \texttt{iso} 文件没有损坏, 一种常用做法是检查其 MD5 值. 71 | 当然, 如果确信自己下载到的文件没有问题, 也可以跳过这一步. 72 | 打开 \textsf{cmd} 窗口依次执行以下代码 73 | \begin{lstlisting} 74 | cd /d X:\Y 75 | certutil -hashfile texlive2025.iso md5 76 | \end{lstlisting} 77 | %\begin{lstlisting} 78 | % (Get-FileHash 'X:\Y\texlive2025.iso' -Algorithm MD5).Hash 79 | %\end{lstlisting} 80 | 若系统显示 81 | \begin{lstlisting}[language = {}] 82 | MD5 的 texlive2025.iso 哈希: 83 | 69b4a8882983d9ea521730b5f42175e7 84 | CertUtil: -hashfile 命令成功完成. 85 | \end{lstlisting} 86 | 则表明下载的镜像文件正常. 87 | 除 MD5 值外, 88 | 还可检查 SHA512 值. 89 | 依然是在 \textsf{cmd} 执行 90 | \begin{lstlisting} 91 | cd /d X:\Y 92 | certutil -hashfile texlive2025.iso sha512 93 | \end{lstlisting} 94 | %\begin{lstlisting} 95 | % (Get-FileHash 'X:\Y\texlive2025.iso' -Algorithm SHA512).Hash 96 | %\end{lstlisting} 97 | 若系统显示 98 | \begin{lstlisting}[literate={a}{a}{1} {b}{b}{1} {c}{c}{1} {d}{d}{1} {e}{e}{1} {f}{f}{1}] 99 | SHA512 的 texlive2025.iso 哈希: 100 | 1fd9a2234d086f50c832ab3ac8b83477bbc39b1138a3c4a2351244c1fd4b8bea6d1ac81d4a5b0cba95f2e82c00f0d9df5b33189eb222e4bae5dae1523ef0da0e 101 | CertUtil: -hashfile 命令成功完成. 102 | \end{lstlisting} 103 | 即为验证成功. 104 | 105 | 接下来开始安装. 106 | 推荐用户先手动建立 \TeX~Live 的安装路径 (文件夹) 再进行安装, 107 | 注意路径的名称是\textbf{不带空格的英文}, 108 | 默认路径为 \path{C:\texlive\2025\}. 109 | 假如系统用了中文作为用户名, 110 | 那么用户需要先按照 \ref{sec:chinesename} 节的方法更改临时环境变量后再安装. 111 | 将镜像文件装载至虚拟光驱% 112 | \footnote{Windows 11 默认双击镜像文件便可装载; 113 | 受某些压缩软件影响双击失效时, 114 | 可在文件夹菜单栏 115 | \menu{装载}; 116 | 第三方虚拟光驱软件可考虑 WinCDEmu 或 UltraISO; 117 | 不鼓励解压缩镜像文件}. 118 | 假设加载后的路径为 \path{Z:\}. 119 | 打开 \textsf{cmd} 窗口并执行 120 | \begin{lstlisting} 121 | Z:\install-tl-windows.bat --no-gui 122 | \end{lstlisting} 123 | %\begin{lstlisting} 124 | % & 'Z:\install-tl-windows.bat' --no-gui 125 | %\end{lstlisting} 126 | 即可看到如下结果 127 | \begin{lstlisting}[language = {}, deleteemph = set] 128 | ======================> TeX Live installation procedure <===================== 129 | 130 | ======> Letters/digits in indicate <======= 131 | ======> menu items for actions or customizations <======= 132 | = help> https://tug.org/texlive/doc/install-tl.html <======= 133 | 134 | Detected platform: Windows (64-bit) 135 | 136 | set binary platforms: 1 out of 15 137 | 138 | set installation scheme: scheme-full 139 | 140 | set installation collections: 141 | 41 collections out of 41, disk space required: 9033 MB (free: 261418 MB) 142 | 143 | set directories: 144 | TEXDIR (the main TeX directory): 145 | C:/texlive/2025 146 | TEXMFLOCAL (directory for site-wide local files): 147 | C:/texlive/texmf-local 148 | TEXMFSYSVAR (directory for variable and automatically generated data): 149 | C:/texlive/2025/texmf-var 150 | TEXMFSYSCONFIG (directory for local config): 151 | C:/texlive/2025/texmf-config 152 | TEXMFVAR (personal directory for variable and automatically generated data): 153 | ~/.texlive2025/texmf-var 154 | TEXMFCONFIG (personal directory for local config): 155 | ~/.texlive2025/texmf-config 156 | TEXMFHOME (directory for user-specific files): 157 | ~/texmf 158 | 159 | options: 160 | [ ] use letter size instead of A4 by default 161 | [X] allow execution of restricted list of programs via \write18 162 | [X] create all format files 163 | [X] install macro/font doc tree 164 | [X] install macro/font source tree 165 | [X] adjust search path 166 | [1] add menu items, shortcuts, etc. 167 | [1] update file associations 168 | [X] install TeXworks front end 169 | [X] after install, set CTAN as source for package updates 170 | 171 | set up for portable installation 172 | 173 | Actions: 174 | start installation to hard disk 175 |

save installation profile to 'texlive.profile' and exit 176 | quit 177 | 178 | Enter command: 179 | \end{lstlisting} 180 | 这时, 用户可直接按键盘 \keys{I} 在默认路径中直接安装 \TeX~Live, 181 | 也可按键盘 \keys{D} 来更改安装路径. 182 | 按 \keys{D} 后, 用户可看到 183 | \begin{lstlisting}[language = {}] 184 | ============================================================================== 185 | Directories customization: 186 | 187 | <1> TEXDIR: C:/texlive/2025 188 | main tree: C:/texlive/2025/texmf-dist 189 | 190 | <2> TEXMFLOCAL: C:/texlive/texmf-local 191 | <3> TEXMFSYSVAR: C:/texlive/2025/texmf-var 192 | <4> TEXMFSYSCONFIG: C:/texlive/2025/texmf-config 193 | 194 | <5> TEXMFVAR: ~/.texlive2025/texmf-var 195 | <6> TEXMFCONFIG: ~/.texlive2025/texmf-config 196 | <7> TEXMFHOME: ~/texmf 197 | 198 | Note: ~ will expand to %USERPROFILE% 199 | 200 | Actions: 201 | return to main menu 202 | quit 203 | 204 | Enter command: 205 | \end{lstlisting} 206 | 这时按键盘 \keys{1}, 将看到 207 | \begin{lstlisting}[language = {}] 208 | New value for TEXDIR [C:/texlive/2025]: 209 | \end{lstlisting} 210 | 这时可更改路径, 如 \path{D:/texlive/2025}. 211 | 接下来, 按键盘 \keys{R} 即可回到初始的安装界面, 212 | 再按键盘 \keys{I} 便可在刚才指定的路径安装. 213 | 用户可通过阅读英文执行其他操作, 这里不再赘述. 214 | 至此, 用户只需耐心等待安装完成, 并且不要点击 \textsf{cmd} 窗口% 215 | \footnote{Windows 11 默认采取快速编辑模式, 一旦点击 \textsf{cmd} 窗口, 216 | 将显示``选择命令提示符''而导致进程暂停}. 217 | 安装完成后, 关闭再打开 \textsf{cmd} 窗口% 218 | \footnote{正常安装 \TeX~Live 后, 环境变量会变化, 219 | 关闭原 \textsf{cmd} 窗口再重新打开才能获取新的环境变量}, 220 | 执行 221 | \begin{lstlisting} 222 | tex -v 223 | \end{lstlisting} 224 | 显示 225 | \begin{lstlisting}[language = {}] 226 | TeX 3.141592653 (TeX Live 2025) 227 | kpathsea version 6.4.1 228 | Copyright 2025 D.E. Knuth. 229 | There is NO warranty. Redistribution of this software is 230 | covered by the terms of both the TeX copyright and 231 | the Lesser GNU General Public License. 232 | For more information about these matters, see the file 233 | named COPYING and the TeX source. 234 | Primary author of TeX: D.E. Knuth. 235 | \end{lstlisting} 236 | 即可认为安装顺利完成% 237 | \footnote{若未能正确显示结果, 则可能是因为环境变量未改变, 238 | 用户可手动添加 \path{\bin\windows} 至环境变量, 239 | \path{} 需与你方才的安装路径一致}. 240 | 弹出前面装载的光盘镜像, 241 | 安装到此结束. 242 | 243 | \subsection{下载镜像一直不成功的处理办法} 244 | 245 | 目前发现有些用户使用某些浏览器时无法正常下载镜像文件. 246 | 这时, 247 | 用户可以选择使用 \href{https://eternallybored.org/misc/wget/}{\textsf{wget}} 对镜像进行下载. 248 | 具体用法是: 249 | 将 \textsf{wget} 所在目录添加到环境变量中. 250 | 打开 \textsf{cmd} 窗口执行以下代码 251 | \begin{lstlisting}[escapechar = |] 252 | wget |\url{http://mirrors.ctan.org/systems/texlive/Images/texlive2025.iso}| 253 | \end{lstlisting} 254 | %\begin{lstlisting} 255 | % Invoke-WebRequest -Uri 'http://mirrors.ctan.org/systems/texlive/Images/texlive2025.iso' -OutFile 'texlive2025.iso' 256 | %\end{lstlisting} 257 | 即可下载最近的镜像. 258 | 类似地, 259 | 也可以指定国内的源进行下载, 260 | 例如选择清华大学镜像 261 | \begin{lstlisting}[escapechar = |] 262 | wget |\url{https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/Images/texlive2025.iso}| 263 | \end{lstlisting} 264 | %\begin{lstlisting} 265 | % Invoke-WebRequest -Uri 'https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/Images/texlive2025.iso' -OutFile 'texlive2025.iso' 266 | %\end{lstlisting} 267 | 其他国内镜像只需要将链接替换即可, 268 | 链接和方法请参考附录~\ref{chp:appendix:mirror}. 269 | 270 | \subsection{需要管理员权限的处理办法} 271 | 272 | 有些用户反馈安装过程中需要管理员权限. 273 | 以管理员身份打开 \textsf{cmd} 窗口的方法是点击 \keys{\faWindows}, 274 | 输入 \textsf{cmd}, 275 | 按 \keys{\ctrl + \shift + \enter} 三个键. 276 | 一般而言, 277 | 在系统盘内直接安装 \TeX~Live 会碰到此类问题, 278 | 因此鼓励用户在安装前先手动建立安装路径. 279 | 直接使用管理员身份打开 \textsf{cmd} 窗口进行安装可能会对以后的升级造成影响. 280 | 281 | \subsection{系统用中文作为用户名}\label{sec:chinesename} 282 | 283 | 很多中文 Windows 用户习惯于用中文作为用户名, 284 | 但是这样会导致 \TeX~Live 安装失败. 285 | 更改系统的 \texttt{TEMP} 和 \texttt{TMP} 这两个环境变量可以避免这样的问题. 286 | 在 \textsf{cmd} 中执行 287 | \begin{lstlisting} 288 | mkdir C:\temp 289 | set TEMP=C:\temp 290 | set TMP=C:\temp 291 | \end{lstlisting} 292 | %\begin{lstlisting} 293 | % New-Item -ItemType Directory -Path 'C:\temp' -Force 294 | % $env:TEMP = 'C:\temp' 295 | % $env:TMP = 'C:\temp' 296 | %\end{lstlisting} 297 | 便可更改这两个环境变量为 \path{C:\temp}. 298 | 更改后按照前述内容安装 \TeX~Live 即可. 299 | 这样的更改是临时的, 300 | 待 \textsf{cmd} 窗口关闭, 301 | 环境变量将恢复为原始状态. 302 | 303 | \section{升级宏包}\label{sec:windows:update} 304 | 305 | 安装完成后, 用户可以升级宏包以获得更好的使用体验. 306 | 下面将介绍使用命令行升级宏包的方法. 307 | 打开 \textsf{cmd} 窗口, 首先执行下面命令指定升级使用的镜像源. 308 | \texttt{ctan} 表示系统在升级时将自动寻求最近的源进行下载. 309 | \begin{lstlisting} 310 | tlmgr option repository ctan 311 | \end{lstlisting} 312 | 用户同样可以指定其他的镜像源, 313 | 方法见附录~\ref{chp:appendix:mirror}. 314 | 315 | 接下来, 用户执行命令 316 | \begin{lstlisting} 317 | tlmgr update --list 318 | \end{lstlisting} 319 | 可查看目前源上可升级的宏包都有哪些. 320 | 高级用户可以根据自己的需求选择升级特定宏包. 321 | 建议初级用户直接升级全部宏包. 322 | 用户只需执行 323 | \begin{lstlisting} 324 | tlmgr update --self --all 325 | \end{lstlisting} 326 | 同时升级 "tlmgr" 本身和全部宏包. 327 | 328 | \subsection{\texttt{tlmgr} 本身无法成功升级} 329 | 330 | 遇到这种情况时, 用户需自行下载并运行 331 | \href{https://mirrors.ctan.org/systems/texlive/tlnet/update-tlmgr-latest.exe}{\texttt{update-tlmgr-latest.exe}}, 332 | 然后再执行升级命令即可% 333 | \footnote{这里依旧让系统自动选择镜像源, 334 | 用户可以自行选择国内镜像以加快下载速度}. 335 | 336 | \subsection{升级到一半停止} 337 | 338 | 这种情况下, 用户需要执行另外一个命令继续升级 339 | \begin{lstlisting} 340 | tlmgr update --reinstall-forcibly-removed --all 341 | \end{lstlisting} 342 | 343 | \subsection{升级宏包的必要性} 344 | 345 | 自本手册撰写以来, 346 | 每年镜像文件打包时都可能存在一些问题, 347 | 具体讨论见% 348 | \href{https://github.com/CTeX-org/ctex-kit/issues/569}{这里}. 349 | 用户安装完毕后, 350 | 请按照本节提供的方法升级. 351 | 352 | \section{安装宏包} 353 | 354 | 在默认状态下, 用户将完整安装 \TeX~Live, 因此用户极少碰到需要手动安装宏包的情形. 355 | 同时, 在 356 | \href{http://mirrors.ctan.org/info/lshort/chinese/lshort-zh-cn.pdf}{\textsf{lshort-zh-cn}} 357 | 中也明确提到, \textbf{如非万不得已, 尽量不要手动安装宏包}. 358 | 因此在这里我只介绍从源处安装宏包的命令. 359 | 假设用户想安装 \texttt{mcmthesis} 宏包, 只需在 \textsf{cmd} 执行 360 | \begin{lstlisting} 361 | tlmgr install mcmthesis 362 | \end{lstlisting} 363 | 需要注意的是, 用户一定要清楚所要安装的宏包名称, 并且在安装宏包前先确保镜像源设置正确. 364 | 365 | \section{调出宏包手册} 366 | 367 | 当正确安装后, 368 | 用户可以调出宏包手册以查阅相应内容. 369 | 例如在 \textsf{cmd} 执行 370 | \begin{lstlisting} 371 | texdoc texlive-zh-cn 372 | \end{lstlisting} 373 | 或 374 | \begin{lstlisting} 375 | texdoc lshort-zh-cn 376 | \end{lstlisting} 377 | 就可分别调出 \texttt{texlive-zh-cn.pdf} 和 \texttt{lshort-zh-cn.pdf}, 378 | 这两本手册中都有讲解安装的相关内容, 379 | 建议用户阅读. 380 | 381 | 本手册业已被 \TeX~Live 收录, 382 | 调出本手册的命令为 383 | \begin{lstlisting} 384 | texdoc install-latex-guide-zh-cn 385 | \end{lstlisting} 386 | 387 | \section{编译文档}\label{sec:windows:compile} 388 | 389 | 升级宏包完成后, 用户可以编译文档. 390 | 这里依旧使用命令行来完成这一过程. 391 | 392 | 首先, 用户需要在指定位置\footnote{以下称工作路径}建立一个 \texttt{tex} 文件: 393 | \begin{lstlisting}[deletekeywords = tex] 394 | mkdir D:\work-latex 395 | cd /d D:\work-latex 396 | notepad main.tex 397 | \end{lstlisting} 398 | %\begin{lstlisting} 399 | % Set-Location (New-Item -ItemType Directory -Path 'D:\work-latex' -Force) 400 | % notepad.exe main.tex 401 | %\end{lstlisting} 402 | 第 1 行表示创建一个工作路径 \path{D:\work-latex}, 403 | 第 2 行表示进入工作路径, 第 3 行表示用记事本打开 \texttt{main.tex} 文件, 404 | 若文件不存在, 系统将询问用户是否创建该文件% 405 | \footnote{Windows 11 对中文名变得友好一些了, 406 | 但这里不建议用户使用中文命名工作路径和文件名}. 407 | 在打开的记事本中编写一个最小示例 408 | \begin{lstlisting}[language = mwe] 409 | \documentclass{article} 410 | \begin{document} 411 | Hello \LaTeX\ World! 412 | \end{document} 413 | \end{lstlisting} 414 | 保存并退出. 415 | 接下来执行 416 | \begin{lstlisting} 417 | pdflatex main 418 | \end{lstlisting} 419 | 等待系统完成编译过程. 420 | 待编译完成后, 我们即可看到在 \path{D:\work-latex\} 421 | 中出现了 \texttt{main.pdf} 文件和其他同名的辅助文件 422 | \texttt{main.aux} 与 \texttt{main.log}. 423 | 424 | 对于中文文档, 可以在记事本中编写以下最小示例% 425 | \footnote{自 Windows 10 1903 版本开始, 记事本默认使用 UTF-8 编码; 426 | Windows 11 继承了这个特性. 427 | 若使用其他编辑器, 428 | 请注意规定文档编码为 UTF-8, 429 | 这与 430 | \href{http://mirrors.ctan.org/language/chinese/ctex/ctex.pdf#page6}{C\TeX\ 宏集默认使用 \texttt{UTF8} 选项}% 431 | 有关}% 432 | \begin{lstlisting}[language = mwe] 433 | \documentclass[fontset = windows]{ctexart} 434 | \begin{document} 435 | 你好 \LaTeX\ 世界! 436 | \end{document} 437 | \end{lstlisting} 438 | 保存并退出. 439 | 接下来执行 440 | \begin{lstlisting} 441 | xelatex main 442 | \end{lstlisting} 443 | 等待系统完成编译过程. 444 | "xelatex" 编译命令配合 UTF-8 编码和 C\TeX\ 宏集% 445 | \footnote{C\TeX\ 宏集与发行版 C\TeX\ 套装并非是同一事物} 446 | 已经是\textbf{目前主流的中文处理手段}. 447 | "xelatex" 可以使用系统内安装的字体, 448 | 用户在安装字体时需右键字体文件的快捷菜单 \menu{显示更多选项 > 为所有用户安装}. 449 | 450 | 总结一下, 在使用 \LaTeX\ 时, 用户首先要在工作路径% 451 | \footnote{建议不同的工程放入不同的工作路径}% 452 | 中建立一个完整的 \texttt{tex} 文件% 453 | \footnote{该文件必须包含 "\documentclass", 454 | "\begin{document}" 和 455 | "\end{document}", 456 | 这里不讨论包含子文件的情况, 457 | 文件名需为不含空格的英文}. 458 | 当 \texttt{tex} 文件内容确定后, 再保存文件并使用编译命令% 459 | \footnote{目前常用的编译命令为 "pdflatex" 和 "xelatex"}, 460 | 将 \texttt{tex} 文件编译成 \texttt{pdf} 文件. 461 | 462 | 编译命令有很多可选参数, 如用户能够从 \texttt{pdf} 文件跳回 \texttt{tex} 文件, 463 | 便是因为执行编译时添加了参数 464 | \begin{lstlisting} 465 | pdflatex -synctex=1 main 466 | \end{lstlisting} 467 | 有些编译还需要额外调用系统命令, 468 | 例如使用 \textsf{minted} 包就有这类要求, 469 | 因此可以在执行编译时添加参数 470 | \begin{lstlisting} 471 | pdflatex -shell-escape main 472 | \end{lstlisting} 473 | 此外还有很多其他参数, 用户若感兴趣, 可自行阅读手册. 474 | 475 | 在很多时候, 我个人更倾向于使用 "latexmk" 来编译 \texttt{tex} 文档, 476 | 如执行 477 | \begin{lstlisting} 478 | latexmk -pdf -synctex=1 -interaction=nonstopmode main 479 | \end{lstlisting} 480 | 意味着使用 481 | \begin{lstlisting} 482 | pdflatex -synctex=1 -interaction=nonstopmode main 483 | \end{lstlisting} 484 | 来编译文档 \texttt{main.tex}, 并在有需要时完成其他步骤% 485 | \footnote{如使用 "bibtex" 或 "biblatex" 处理参考文献时需要多次编译, 486 | 详情见相关文档}. 487 | 488 | \subsection{\LaTeXe\ 版本不匹配导致 \texttt{xelatex} 失败} 489 | 490 | 使用 "xelatex" 编译文档, 491 | 系统有时会提示目前 \LaTeXe\ 的版本低于某宏包的要求版本. 492 | 这种情况是由于 \textsf{fmt} 文件未能更新所导致. 493 | 此时可考虑在命令行运行 494 | \begin{lstlisting} 495 | fmtutil-user --byfmt xelatex 496 | \end{lstlisting} 497 | 待结束后再用 "xelatex" 编译文档. 498 | 更多内容参考 499 | \href{https://github.com/CTeX-org/forum/issues/70}{GitHub 上的讨论}. 500 | 501 | 另外也可考虑重装 "xetex". 502 | 在命令行执行 503 | \begin{lstlisting} 504 | tlmgr install --reinstall xetex 505 | \end{lstlisting} 506 | 507 | \subsection{编译出现 \texttt{l3backend-*} 问题} 508 | 509 | 这是 \texttt{fmt} 文件未能更新所导致的问题. 510 | 可以用 511 | \begin{lstlisting} 512 | fmtutil-sys --all 513 | \end{lstlisting} 514 | 刷新 \texttt{fmt} 文件后再编译 \texttt{tex} 文件. 515 | 516 | \section{卸载 \TeX~Live} 517 | 518 | 在跨版本升级 \TeX~Live 时, 通常需要卸载旧版 \TeX~Live. 519 | 下面介绍几种卸载方法. 520 | 521 | \subsection{使用批处理文件} 522 | 523 | 在命令行执行 524 | \begin{lstlisting} 525 | kpsewhich -var-value TEXMFROOT 526 | \end{lstlisting} 527 | 可以查看 \path{TEXMFROOT} 的值, 528 | 该值即为 \TeX~Live 的安装路径% 529 | \footnote{除这里提供的 \path{TEXMFROOT}, 还有很多其他变量, 可在 530 | \href{https://www.tug.org/texlive/doc/texlive-zh-cn/texlive-zh-cn.pdf}{texlive-zh-cn} 531 | 第 2.3 节处找到}. 532 | 接下来, 533 | 用户只需执行% 534 | \footnote{双击或在 \textsf{cmd} 中运行}% 535 | 安装路径中的卸载批处理文件即可实现卸载, 如默认安装时执行 536 | \begin{lstlisting} 537 | C:\texlive\2025\tlpkg\installer\uninst.bat 538 | \end{lstlisting} 539 | %\begin{lstlisting} 540 | % & 'C:\texlive\2025\tlpkg\installer\uninst.bat' 541 | % Remove-Item -Recurse -Force -Path '$env:USERPROFILE\.texlive2025' 542 | %\end{lstlisting} 543 | 结束以上步骤后, 544 | 手动删除用户文件夹中的 \texttt{.texlive2025}. 545 | 如果用户安装 \TeX~Live 时需要管理员权限, 546 | 那么在卸载时同样需要管理员权限. 547 | 548 | 卸载后, 549 | 用户需要清理注册表 550 | \begin{lstlisting}[language = {}] 551 | HKEY_CURRENT_USER\Software\Classes\TL.DVIOUT.view.2025 552 | HKEY_CURRENT_USER\Software\Classes\TL.TeXworks.edit.2025 553 | HKEY_CURRENT_USER\Software\Classes\TL.PSViewer.view.2025 554 | HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts\TL.TeXworks.edit.2025_.tex 555 | \end{lstlisting} 556 | 但若在安装时使用管理员权限``为所有人安装'', 557 | 则注册表位置将变为 558 | \begin{lstlisting}[language = {}] 559 | HKEY_LOCAL_MACHINE\SOFTWARE\Classes\TL.DVIOUT.view.2025 560 | HKEY_LOCAL_MACHINE\SOFTWARE\Classes\TL.TeXworks.edit.2025 561 | HKEY_LOCAL_MACHINE\SOFTWARE\Classes\TL.PSViewer.view.2025 562 | \end{lstlisting} 563 | 564 | \subsection{手动卸载} 565 | 566 | 如果执行批处理文件 \texttt{uninst.bat} 出错, 567 | 用户也可手动删除安装文件夹, 568 | 之后再清理 \TeX~Live 的环境变量, 569 | 并且清理注册表. 570 | 571 | \section{跨版本升级 \TeX~Live} 572 | 573 | 目前在 \href{https://www.tug.org/texlive/upgrade.html}{\texttt{tug.org}} 574 | 上面提供的说法是: 575 | Windows 没有类似 Unix 的升级程序, 576 | 需要进行新安装% 577 | \footnote{原文是: There is no comparable upgrade procedure for Windows. 578 | Doing a new installation is necessary}. 579 | -------------------------------------------------------------------------------- /chapter/wsl.tex: -------------------------------------------------------------------------------- 1 | % !TeX root = ../install-latex-guide-zh-cn.tex 2 | 3 | \chapter{Windows Subsystem for Linux} 4 | 5 | 目前微软推出了 Windows Subsystem for Linux (WSL) 供开发人员使用. 6 | 在这里简要介绍如何在 WSL 中安装 \TeX~Live. 7 | 我选择的是 Windows 11 微软商店中的 Ubuntu. 8 | 此篇安装教程仅供参考. 9 | 这里称 WSL 中使用的命令行为 \textsf{bash}. 10 | \textbf{不建议}对操作系统了解不多的用户阅读本章内容. 11 | 12 | \section{安装 \TeX~Live} 13 | 14 | 在主系统\footnote{在 Windows 11 中直接进行的操作即为在主系统中的操作}% 15 | 中下载 16 | \href{https://mirrors.ctan.org/systems/texlive/Images/texlive2025.iso}{\texttt{iso} 镜像文件}, 17 | 可选择国内源以加快下载速度. 18 | 下载完毕后, 在 \textsf{cmd} 中验证文件是否正常. 19 | 下载及文件验证方法同 \ref{sec:windows:install}~节. 20 | 21 | 在正式安装前, 22 | 用户需要在 \textsf{bash} 中执行 23 | \begin{lstlisting} 24 | sudo apt install fontconfig gedit 25 | \end{lstlisting} 26 | 以减少后续字体问题和文本编辑问题. 27 | 在 Windows 11 中, 28 | WSL 已经能够自动完成可视化工作, 29 | 这为一些用户提供了便利. 30 | 为避免安装速度过慢, 31 | 可仿照 \ref{sec:addition:source}~节更改文件 \texttt{sources.list}. 32 | 不习惯在 "gedit" 中做文本操作的 Windows 用户, 33 | 可参考 \ref{sec:addition:wsl-editor}~节. 34 | 35 | 接下来, 在主系统中将镜像装载, 36 | 例如挂载到 \path{X:\}, 37 | 而后进入 \textsf{bash} 并执行如下命令 38 | \begin{lstlisting} 39 | sudo mkdir /mnt/x 40 | sudo mount -t drvfs X: /mnt/x 41 | \end{lstlisting} 42 | 如此便可在 \textsf{bash} 中找到装载的光盘镜像. 43 | 之后执行 44 | \begin{lstlisting} 45 | sudo /mnt/x/install-tl 46 | \end{lstlisting} 47 | 进行安装. 48 | 在屏幕上应该能见到以下内容 49 | \begin{lstlisting}[language = {}, deleteemph = set] 50 | ======================> TeX Live installation procedure <===================== 51 | 52 | ======> Letters/digits in indicate <======= 53 | ======> menu items for actions or customizations <======= 54 | = help> https://tug.org/texlive/doc/install-tl.html <======= 55 | 56 | Detected platform: GNU/Linux on x86_64 57 | 58 | set binary platforms: 1 out of 15 59 | 60 | set installation scheme: scheme-full 61 | 62 | set installation collections: 63 | 40 collections out of 41, disk space required: 8779 MB (free: 974100 MB) 64 | 65 | set directories: 66 | TEXDIR (the main TeX directory): 67 | /usr/local/texlive/2025 68 | TEXMFLOCAL (directory for site-wide local files): 69 | /usr/local/texlive/texmf-local 70 | TEXMFSYSVAR (directory for variable and automatically generated data): 71 | /usr/local/texlive/2025/texmf-var 72 | TEXMFSYSCONFIG (directory for local config): 73 | /usr/local/texlive/2025/texmf-config 74 | TEXMFVAR (personal directory for variable and automatically generated data): 75 | ~/.texlive2025/texmf-var 76 | TEXMFCONFIG (personal directory for local config): 77 | ~/.texlive2025/texmf-config 78 | TEXMFHOME (directory for user-specific files): 79 | ~/texmf 80 | 81 | options: 82 | [ ] use letter size instead of A4 by default 83 | [X] allow execution of restricted list of programs via \write18 84 | [X] create all format files 85 | [X] install macro/font doc tree 86 | [X] install macro/font source tree 87 | [ ] create symlinks to standard directories 88 | [X] after install, set CTAN as source for package updates 89 | 90 | set up for portable installation 91 | 92 | Actions: 93 | start installation to hard disk 94 |

save installation profile to 'texlive.profile' and exit 95 | quit 96 | 97 | Enter command: 98 | \end{lstlisting} 99 | 用户直接点击 \keys{I} 使用默认配置安装. 100 | 如果用户对于 WSL 比较了解, 可以根据提示, 更改安装设置. 101 | 与第~\ref{chap:ubuntu:sec:install}~节一样, 102 | 为简化起见, 103 | 以下记录均假定为 \path{x86_64} 上的默认安装. 104 | 安装完毕后, 需继续在 \textsf{bash} 中执行 105 | \begin{lstlisting} 106 | sudo umount /mnt/x 107 | sudo rmdir /mnt/x 108 | \end{lstlisting} 109 | 弹出已装载的光盘镜像. 110 | 111 | 默认安装完成后, 用户需要设置环境变量. 112 | 继续在 \textsf{bash} 中执行 113 | \begin{lstlisting} 114 | gedit ~/.profile 115 | \end{lstlisting} 116 | 在打开的文件末尾添加 117 | \begin{lstlisting}[deletekeywords = local] 118 | # Add TeX Live to the PATH, MANPATH, INFOPATH 119 | export PATH=/usr/local/texlive/2025/bin/x86_64-linux:$PATH 120 | export MANPATH=/usr/local/texlive/2025/texmf-dist/doc/man:$MANPATH 121 | export INFOPATH=/usr/local/texlive/2025/texmf-dist/doc/info:$INFOPATH 122 | \end{lstlisting} 123 | 并保存退出. 124 | 同样, 125 | 不习惯于 "gedit" 处理文本的 Windows 用户可参考 \ref{sec:addition:wsl-editor}~节. 126 | 退出 WSL 再进入, 127 | 执行 128 | \begin{lstlisting} 129 | tex -v 130 | \end{lstlisting} 131 | 将显示 132 | \begin{lstlisting}[language = {}] 133 | TeX 3.141592653 (TeX Live 2025) 134 | kpathsea version 6.4.1 135 | Copyright 2025 D.E. Knuth. 136 | There is NO warranty. Redistribution of this software is 137 | covered by the terms of both the TeX copyright and 138 | the Lesser GNU General Public License. 139 | For more information about these matters, see the file 140 | named COPYING and the TeX source. 141 | Primary author of TeX: D.E. Knuth. 142 | \end{lstlisting} 143 | 即为安装成功. 144 | 145 | 接下来仿照 Ubuntu 24.04 处理字体. 146 | 首先将配置文件复制到系统, 147 | 在 \textsf{bash} 执行 148 | \begin{lstlisting}[deletekeywords = local] 149 | sudo cp /usr/local/texlive/2025/texmf-var/fonts/conf/texlive-fontconfig.conf /etc/fonts/conf.d/09-texlive.conf 150 | \end{lstlisting} 151 | 然后在 \textsf{bash} 执行 152 | \begin{lstlisting} 153 | sudo fc-cache -fsv 154 | \end{lstlisting} 155 | 刷新字体缓存. 156 | 157 | \subsection{在用户文件夹安装} 158 | 159 | WSL 同样也可以在用户文件夹中安装, 160 | 它的用户文件夹往往在主系统的系统盘中. 161 | 具体过程也可以参考第~\ref{subsec:ubuntu-user-folder}~节. 162 | 163 | \section{升级宏包} 164 | 165 | WSL 中的方法同 \ref{sec:ubuntu:update}~节. 166 | 167 | \section{安装宏包} 168 | 169 | WSL 中的方法同 \ref{sec:ubuntu:installpackage}~节. 170 | 171 | \section{调出宏包手册} 172 | 173 | 由于 WSL 的 \textsf{bash} 默认是无窗口化的纯命令行, 174 | 因此将 \TeX~Live 安装至 WSL 后, 175 | 用户无法直接通过命令 "texdoc" 打开相应的手册. 176 | 下面几种方法均为收集而来的方案, 177 | 其中比较推荐更改 \texttt{texdoc.cnf}. 178 | 179 | \subsubsection{更改 \texttt{texdoc.cnf}} 180 | 181 | 此方案源自本手册的 \href{https://github.com/OsbertWang/install-latex-guide-zh-cn/issues/13}{issue}. 182 | 首先在 \textsf{bash} 中执行 183 | \begin{lstlisting} 184 | texdoc --files 185 | \end{lstlisting} 186 | 系统返回类似如下内容 187 | \begin{lstlisting}[language = {}] 188 | /usr/local/texlive/2025/texmf-dist/scripts/texdoc/texdoclib.tlu 4.1.1 189 | Configuration file(s): 190 | active /usr/local/texlive/2025/texmf-dist/texdoc/texdoc.cnf 191 | Recommended file(s) for personal settings: 192 | /home/osbertwang/texmf/texdoc/texdoc.cnf 193 | \end{lstlisting} 194 | 这里给出了 "texdoc" 的配置文件所在位置. 195 | 打开用户文件夹下的配置文件 196 | \begin{lstlisting}[deletekeywords = texdoc] 197 | mkdir -p ~/texmf/texdoc && touch ~/texmf/texdoc/texdoc.cnf 198 | gedit ~/texmf/texdoc/texdoc.cnf 199 | \end{lstlisting} 200 | 在文件内写入 201 | \begin{lstlisting} 202 | viewer_pdf = (powershell.exe -Command Start-Process $(wslpath -w %s)) & 203 | \end{lstlisting} 204 | 并且保存退出. 205 | 然后再执行 "texdoc" 即可打开相应文档. 206 | 207 | \subsubsection{explorer 浏览} 208 | 209 | 先找到手册所在路径, 210 | 例如寻找 \textsf{lshort-zh-cn} 211 | \begin{lstlisting} 212 | texdoc -l lshort-zh-cn 213 | \end{lstlisting} 214 | 系统会显示 215 | \begin{lstlisting}[language = {}] 216 | 1 /usr/local/texlive/2025/texmf-dist/doc/latex/lshort-chinese/lshort-zh-cn.pdf 217 | = [zh] The document itself 218 | Enter number of file to view, RET to view 1, anything else to skip: 219 | \end{lstlisting} 220 | 这时按其他键 (如 \keys{x}) 退出. 221 | 然后分别执行 222 | \begin{lstlisting}[language = {}] 223 | cd /usr/local/texlive/2025/texmf-dist/doc/latex/lshort-chinese/ 224 | explorer.exe . 225 | \end{lstlisting} 226 | 主系统的资源管理器便会打开. 227 | 这时用户便可以在主系统中使用 PDF 阅读器打开手册进行阅读. 228 | 229 | \subsubsection{everything 搜索} 230 | 231 | 使用 \href{https://www.voidtools.com/zh-cn/}{everything}. 232 | 通过 "texdoc -l" 找到相应文件名, 233 | 而后直接搜索. 234 | 具体方法这里不再赘述. 235 | 236 | \subsubsection{借助其他工具} 237 | 238 | 目前有很多开源的 WSL 辅助程序, 239 | 相关讨论见本手册的 \href{https://github.com/OsbertWang/install-latex-guide-zh-cn/issues/13}{issue}. 240 | 241 | \section{编译文件} 242 | 243 | 编译一个最小示例 \texttt{main.tex}. 244 | 245 | 在主系统的 \textsf{cmd} 中执行 246 | \begin{lstlisting}[deletekeywords = tex] 247 | mkdir D:\work-latex 248 | cd /d D:\work-latex 249 | notepad main.tex 250 | \end{lstlisting} 251 | %\begin{lstlisting} 252 | % Push-Location (New-Item -ItemType Directory -Path 'D:\work-latex' -Force) 253 | % notepad.exe main.tex 254 | %\end{lstlisting} 255 | 建立文档, 256 | 内容为 257 | \begin{lstlisting}[language = mwe] 258 | \documentclass{article} 259 | \begin{document} 260 | Hello \LaTeX\ World! 261 | \end{document} 262 | \end{lstlisting} 263 | 接下来在 \textsf{cmd} 中执行 264 | \begin{lstlisting} 265 | bash -l -c "pdflatex main" 266 | \end{lstlisting} 267 | 实现编译. 268 | 269 | 也可以直接在 WSL 中建立文档并编译, 270 | 在 \textsf{bash} 中依次执行 271 | \begin{lstlisting}[deletekeywords = tex] 272 | mkdir /mnt/d/work-latex 273 | cd /mnt/d/work-latex 274 | gedit main.tex 275 | \end{lstlisting} 276 | 建立文档, 277 | 内容同上, 278 | 然后在 \textsf{bash} 中执行 279 | \begin{lstlisting} 280 | pdflatex main 281 | \end{lstlisting} 282 | 实现编译. 283 | 284 | 待编译完成后, 可看到在工作路径中生成了 \texttt{main.pdf} 285 | 文件和其他同名的辅助文件 \texttt{main.aux} 与 \texttt{main.log}. 286 | 在主系统中可以打开 \texttt{main.pdf} 查看内容. 287 | 288 | 对于中文文档, 289 | 可以编写以下最小示例\footnote{注意使用 UTF-8 编码}% 290 | \begin{lstlisting}[language = mwe] 291 | \documentclass[fontset = fandol]{ctexart} 292 | \begin{document} 293 | 你好 \LaTeX\ 世界! 294 | \end{document} 295 | \end{lstlisting} 296 | 在 \textsf{cmd} 中执行 297 | \begin{lstlisting} 298 | bash -l -c "xelatex main" 299 | \end{lstlisting} 300 | 或在 \textsf{bash} 中执行 301 | \begin{lstlisting} 302 | xelatex main 303 | \end{lstlisting} 304 | 等待系统完成编译过程. 305 | "xelatex" 同样可以使用 WSL 内安装的字体% 306 | \footnote{注意主系统中的字体默认不能直接被调用, 307 | 如果打算使用主系统中的字体, 308 | 见 309 | \href{https://github.com/OsbertWang/install-latex-guide-zh-cn/issues/14}{GitHub 上的讨论}, 310 | 鉴于 WSL2 和主系统文件系统互访速度慢, 311 | 该方法很可能拖慢 "xelatex" 速度}, 312 | 在 WSL 中安装字体的方法见 \ref{sec:addition:font}~节. 313 | 314 | 编译命令可添加参数, 这里与 \ref{sec:windows:compile}~节中的情形一致, 不再赘述. 315 | 316 | \section{卸载 \TeX~Live} 317 | 318 | WSL 中的方法同 \ref{sec:ubuntu:uninstall}~节. 319 | 320 | \section{跨版本升级 \TeX~Live} 321 | 322 | WSL 中的方法同 \ref{sec:ubuntu:version}~节. 323 | -------------------------------------------------------------------------------- /install-latex-guide-zh-cn.tex: -------------------------------------------------------------------------------- 1 | \documentclass[fontset = fandol, svgnames]{ctexrep} 2 | 3 | \ctexset{ 4 | chapter = { 5 | format = \huge\bfseries\raggedright, 6 | number = \arabic{chapter}, 7 | name = {}, 8 | tocline = \CTEXifname{\protect\numberline{\thechapter}}{}#2, 9 | }, 10 | section/format = \Large\bfseries\raggedright, 11 | } 12 | 13 | \usepackage[margin = 2.4cm]{geometry} 14 | \usepackage{booktabs, array} 15 | \usepackage{fontawesome6, fancyqr, hologo} 16 | \usepackage[colorlinks, pdfpagelayout = SinglePage, bookmarksnumbered]{hyperref} 17 | 18 | \usepackage{tikz} 19 | \usetikzlibrary{shapes.geometric, calc} 20 | \tikzset{ 21 | score stars/.style = { 22 | % shape 23 | star, star points = 5, star point ratio = 2.25, scale = .8, 24 | % color 25 | draw = gray, fill = #1, 26 | % others 27 | inner sep = 0.14em, anchor = outer point 3 28 | } 29 | } 30 | \newcommand\stars[1]{% 31 | \begin{tikzpicture} 32 | % Draw five stars. For #1 = "2.3", fill the 1st and 2nd stars as gray, 33 | % and fill the 3rd to 5th stars as white. 34 | \foreach \i in {1, ..., 5} { 35 | \pgfmathsetmacro\starcolor{\i<=#1 ? "gray" : "white"} 36 | \node [score stars = \starcolor] (star\i) at (\i*0.8em, 0) {}; 37 | } 38 | % For #1 = "2.3", let \partstar = "3" and \starpart = "0.3". 39 | % Then fill the left 30% part of the 3rd star as gray after clipping. 40 | \pgfmathsetmacro\partstar{#1>int(#1) ? int(#1+1) : 0} 41 | \ifnum\partstar>0 42 | \pgfmathsetmacro\starpart{#1-(int(#1))} 43 | \coordinate (upper left) 44 | at (star\partstar.outer point 2 |- star\partstar.outer point 1); 45 | \coordinate (upper right) 46 | at (star\partstar.outer point 5 |- star\partstar.outer point 1); 47 | \coordinate (lower right) 48 | at (star\partstar.outer point 5 |- star\partstar.outer point 4); 49 | \clip (upper left) rectangle 50 | ({$ (upper left)!\starpart!(upper right) $} |- lower right); 51 | \node [score stars = gray] at (\partstar*0.8em, 0) {}; 52 | \fi 53 | \end{tikzpicture}% 54 | } 55 | 56 | \usepackage[os = win]{menukeys} 57 | \renewmenumacro{\menu}[>]{angularmenus} 58 | \renewmenumacro{\keys}[+]{shadowedroundedkeys} 59 | \renewcommand\RSsmallest{5pt} 60 | \protect\renewcommand\faWindows{% 61 | \tikz[rounded corners = .1pt, baseline = -.25em] 62 | \foreach \i in {0, 90, 180, 270} 63 | \fill [ rotate = \i ] (-.4em, .4em) rectangle (-.025em, .025em); 64 | } 65 | 66 | \usepackage{listings, fancyvrb} 67 | \lstset{ 68 | breaklines = true, 69 | columns = fullflexible, 70 | showstringspaces= false, 71 | tabsize = 4, 72 | gobble = 1, 73 | numbers = left, 74 | numberstyle = \tiny\ttfamily, 75 | numbersep = \ccwd, 76 | frame = lines, 77 | rulecolor = \color{blue!40}, 78 | backgroundcolor = \color{lightgray!20}, 79 | language = bash, 80 | alsoletter = -, 81 | basicstyle = \small\ttfamily, 82 | commentstyle = \color{olive!80!black}, 83 | stringstyle = \color{brown}, 84 | emph = { bash, cd, cp, dpkg, find, grep, ln, md5sum, mkdir, 85 | mount, rm, rmdir, set, sha512sum, sudo, umount }, 86 | emphstyle = \color{blue}\bfseries, 87 | morekeywords = { add-apt-repository, apt, brew, certutil, evince, 88 | fc-cache, fc-list, fmtutil, fmtutil-user, fmtutil-sys, 89 | gedit, kpsewhich, l3build, latexmk, mkfontdir, 90 | mkfontscale, notepad, tex, texdoc, tlmgr, pdflatex, 91 | visudo, wget, wsl, xelatex }, 92 | keywordstyle = \color{teal}\bfseries 93 | } 94 | \lstdefinelanguage{json}{ 95 | basicstyle = \small\ttfamily\color{DarkBlue}, 96 | numberstyle = \tiny\ttfamily\color{black}, 97 | alsoletter = ", 98 | morecomment = [l]{//}, 99 | morekeywords = {"latexmk", "latexmkpdf", "latexmkxe", "never", "tab"}, 100 | keywordstyle = \color{FireBrick}\bfseries, 101 | literate ={*[{\textcolor{DarkGreen}{[ }}1 ]{\textcolor{DarkGreen}{ ]}}1 102 | \{{\textcolor{DarkRed} {\{}}1 \}{\textcolor{DarkRed} {\}}}1 103 | :{\textcolor{black} {:}} 1 ,{\textcolor{black} {,}} 1} 104 | } 105 | \lstdefinelanguage{mwe}{ 106 | language = {[LaTeX]TeX}, 107 | texcsstyle = *\color{violet}, 108 | morekeywords = {article, ctexart, document}, 109 | literate =*\{{\textcolor{magenta}\{}1 \}{\textcolor{magenta}\}}1 110 | } 111 | \lstMakeShortInline [ breaklines = true, basicstyle = \ttfamily, 112 | emphstyle = {}, keywordstyle = {} ] {"} 113 | \VerbatimFootnotes 114 | 115 | \title{\bfseries 一份简短的关于 \LaTeX\ 安装的介绍% 116 | \thanks{\url{https://github.com/OsbertWang/install-latex-guide-zh-cn}}% 117 | } 118 | \author{王然% 119 | \thanks{\href{mailto:ranwang.osbert@outlook.com}% 120 | {\texttt{ranwang.osbert@outlook.com}}}% 121 | } 122 | \date{\today} 123 | 124 | \begin{document} 125 | 126 | \maketitle 127 | 128 | \include{./chapter/preface} 129 | 130 | \tableofcontents 131 | 132 | \include{./chapter/windows} 133 | \include{./chapter/ubuntu} 134 | \include{./chapter/macos} 135 | \include{./chapter/wsl} 136 | \include{./chapter/editor} 137 | \include{./chapter/overleaf} 138 | 139 | \appendix 140 | 141 | \include{./chapter/mirror} 142 | \include{./chapter/addition} 143 | \include{./chapter/offline} 144 | \include{./chapter/updateinfo} 145 | 146 | \end{document} 147 | -------------------------------------------------------------------------------- /make.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | cd %~dp0 3 | set INSTALLLATEX=install-latex-guide-zh-cn 4 | set PDF=%INSTALLLATEX%.pdf 5 | set TEMP=%INSTALLLATEX%.xdv %INSTALLLATEX%.aux %INSTALLLATEX%.log %INSTALLLATEX%.toc %INSTALLLATEX%.out %INSTALLLATEX%.synctex.gz ^ 6 | .\chapter\*.aux 7 | 8 | if "%1"=="clean" goto clean 9 | 10 | set TEX=xelatex 11 | set MODE=-synctex=1 12 | set NOPDFMODE=-synctex=1 --no-pdf 13 | 14 | %TEX% %NOPDFMODE% %INSTALLLATEX% 15 | %TEX% %MODE% %INSTALLLATEX% 16 | exit /B 17 | 18 | :clean 19 | del %TEMP% 20 | del %PDF% 21 | exit /B 22 | -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | INSTALLLATEX = install-latex-guide-zh-cn 2 | PDF = $(INSTALLLATEX).pdf 3 | REQUIRE = $(INSTALLLATEX).tex $(wildcard ./chapter/*.tex) 4 | TEMP = $(INSTALLLATEX).xdv $(INSTALLLATEX).aux $(INSTALLLATEX).log $(INSTALLLATEX).toc $(INSTALLLATEX).out $(INSTALLLATEX).synctex.gz \ 5 | $(wildcard ./chapter/*.aux) 6 | 7 | TEX = xelatex 8 | MODE = -synctex=1 9 | NOPDFMODE = -synctex=1 --no-pdf 10 | 11 | all: $(PDF) 12 | 13 | $(PDF): $(REQUIRE) 14 | $(TEX) $(NOPDFMODE) $(INSTALLLATEX) 15 | $(TEX) $(MODE) $(INSTALLLATEX) 16 | 17 | clean: 18 | rm $(PDF) $(TEMP) 19 | 20 | .PHONY: all clean --------------------------------------------------------------------------------