为什么我无法构建和查看 PdfLaTeX?

为什么我无法构建和查看 PdfLaTeX?
Could not start Build & View:PdfLaTeX:
pdflatex -synctex=1 -interaction=nonstopmode "moderncv".tex.

当我尝试使用 构建我的项目时F5,我收到上述错误。我不明白为什么。我的项目的文件结构如下:

在此处输入图片描述

我不明白为什么我现在会收到这个错误。

texlive 已经安装在我的系统上。sudo apt-get install texlive在我的Ubuntu,我得到:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
texlive is already the newest version (2015.20160320-1).
The following packages were automatically installed and are no longer required:
  linux-headers-4.4.0-72 linux-headers-4.4.0-72-generic
  linux-image-4.4.0-72-generic linux-image-extra-4.4.0-72-generic
  linux-signed-image-4.4.0-72-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 214 not upgraded.

我目前遇到这些错误特克斯工作室

pdflatex cv_7当我在项目文件夹中调用该命令时,我得到:

This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./cv_7.tex
LaTeX2e <2016/02/01>
Babel <3.9q> and hyphenation patterns for 3 language(s) loaded.
(./moderncv.cls
Document Class: moderncv 2012/10/31 v1.2.0 modern curriculum vitae and letter d
ocument class
(/usr/share/texlive/texmf-dist/tex/latex/base/size11.clo)
(/usr/share/texlive/texmf-dist/tex/latex/etoolbox/etoolbox.sty)
(/usr/share/texlive/texmf-dist/tex/latex/base/ifthen.sty)
(/usr/share/texlive/texmf-dist/tex/latex/xcolor/xcolor.sty
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/color.cfg)
(/usr/share/texlive/texmf-dist/tex/latex/pdftex-def/pdftex.def
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)))
(/usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/t1enc.def))
(/usr/share/texmf/tex/latex/lm/lmodern.sty)
(/usr/share/texlive/texmf-dist/tex/latex/url/url.sty)
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/graphics.cfg)))
(/usr/share/texlive/texmf-dist/tex/latex/fancyhdr/fancyhdr.sty)
(/usr/share/texlive/texmf-dist/tex/latex/tools/calc.sty)
(/usr/share/texlive/texmf-dist/tex/latex/xargs/xargs.sty
(/usr/share/texlive/texmf-dist/tex/latex/xkeyval/xkeyval.sty
(/usr/share/texlive/texmf-dist/tex/generic/xkeyval/xkeyval.tex
(/usr/share/texlive/texmf-dist/tex/generic/xkeyval/xkvutils.tex))))
(/usr/share/texlive/texmf-dist/tex/latex/microtype/microtype.sty
(/usr/share/texlive/texmf-dist/tex/latex/microtype/microtype-pdftex.def)
(/usr/share/texlive/texmf-dist/tex/latex/microtype/microtype.cfg))
(./moderncvcompatibility.sty)
(/usr/share/texlive/texmf-dist/tex/latex/bigfoot/suffix.sty) (./tweaklist.sty))
 (./moderncvstyleclassic.sty
(/usr/share/texlive/texmf-dist/tex/latex/marvosym/umvs.fd))
(./moderncvcolorpurple.sty)
(/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty))
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hyperref.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty))
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/auxhook.sty)
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/kvoptions.sty)
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/pd1enc.def)
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/hyperref.cfg)
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/puenc.def))

Package hyperref Message: Driver (autodetected): hpdftex.

(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hpdftex.def
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty))
(./cv_7.aux) (/usr/share/texmf/tex/latex/lm/t1lmr.fd)
(/usr/share/texlive/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/share/texlive/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/grfext.sty)
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
(/usr/share/texlive/texmf-dist/tex/latex/microtype/mt-cmr.cfg)
(/usr/share/texmf/tex/latex/lm/t1lmss.fd)
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/nameref.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/gettitlestring.sty))
(./cv_7.out) (./cv_7.out) (/usr/share/texmf/tex/latex/lm/ot1lmr.fd)
(/usr/share/texmf/tex/latex/lm/omllmm.fd)
(/usr/share/texmf/tex/latex/lm/omslmsy.fd)
(/usr/share/texmf/tex/latex/lm/omxlmex.fd)
(/usr/share/texlive/texmf-dist/tex/latex/microtype/mt-mvs.cfg)
<pictures/picture.JPG, id=27, 1183.3008pt x 1135.1208pt>
<use pictures/picture.JPG>
Underfull \hbox (badness 10000) in paragraph at lines 56--56


LaTeX Font Warning: Font shape `T1/lmss/m/sc' in size <10.95> not available
(Font)              Font shape `T1/lmr/m/sc' tried instead on input line 80.


Underfull \hbox (badness 10000) in paragraph at lines 80--80


Underfull \hbox (badness 10000) in paragraph at lines 82--82


Underfull \hbox (badness 10000) in paragraph at lines 86--86


Underfull \hbox (badness 10000) in paragraph at lines 90--90

[1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map} <./pictures/picture.JPG>]

Underfull \hbox (badness 10000) in paragraph at lines 95--95

[2] (./cv_7.aux)

Package rerunfilecheck Warning: File `cv_7.out' has changed.
(rerunfilecheck)                Rerun to get outlines right
(rerunfilecheck)                or use package `bookmark'.

 )
(see the transcript file for additional information){/usr/share/texmf/fonts/enc
/dvips/lm/lm-ec.enc}</usr/share/texmf/fonts/type1/public/lm/lmcsc10.pfb></usr/s
hare/texmf/fonts/type1/public/lm/lmss10.pfb></usr/share/texmf/fonts/type1/publi
c/lm/lmss12.pfb></usr/share/texmf/fonts/type1/public/lm/lmss17.pfb></usr/share/
texmf/fonts/type1/public/lm/lmss8.pfb></usr/share/texmf/fonts/type1/public/lm/l
mssbx10.pfb></usr/share/texmf/fonts/type1/public/lm/lmsso10.pfb></usr/share/tex
mf/fonts/type1/public/lm/lmsso17.pfb></usr/share/texlive/texmf-dist/fonts/type1
/public/marvosym/marvosym.pfb>
Output written on cv_7.pdf (2 pages, 3521903 bytes).
Transcript written on cv_7.log.

答案1

如果您的主文档是cv_7.tex,Texstudio 显然使用了错误的根文档,因为它运行pdflatex的是"moderncv".tex而不是"cv_7".tex

更改根文档有多种方式:

  • 在 Texstudio 中打开cv_7.tex并单击选择菜单项OptionsRoot DocumentSet Current Document as Explicit Root。这将设置cv_7.tex为根文档。
  • 在 Texstudio 中打开cv_7.tex并右键单击cv_7.tex结构视图(Texstudio 窗口左侧)并选择set as explicit root document。这将设置cv_7.tex为根文档。
  • 在 Texstudio 中打开cv_7.tex并单击选择菜单项OptionsRoot DocumentDetect Automatically。这将取消设置当前根文档并切换回使用当前文档作为根。
  • 在 Texstudio 中右键单击moderncv.tex结构视图(Texstudio 窗口左侧)并选择remove explicit root document role。这将取消moderncv.tex设置为根文档,并切换回使用当前文档作为根文档。
  • 删除现有的魔术评论来自文档。这将是这样的一行

    % !TeX root = moderncv.tex
    

    这样的行将设置一个根文档,并且如果它仅由魔术注释设置,则moderncv.tex删除该行将重置为根文档。moderncv.tex

  • 添加魔术评论就您的情况而言,在文档的最开头:

    % !TeX root = cv_7.tex
    

    这将设置cv_7.tex为根文档,但如果已使用菜单或结构视图将另一个文档设置为明确的根,则该文档不起作用。

注意:您不需要使用上述所有解决方案。请逐一尝试并测试 Texstudio 是否能编译cv_7.tex

Texstudio 手册中的第 4.1.1 节“根文档”有关根文档的更多信息。

相关内容