我一直想尝试用RStudio用西班牙语创建PDF文件。
当我编织没有任何lang
规范的文档时,一切正常。这是一个.Rmd文件,呈现时没有任何问题:
[test_file.Rmd]
---
title: "Lorem ipsum test"
output:
pdf_document:
toc: yes
html_notebook: default
abstract: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vel
euismod metus."
---
# Lorem ipsum 1
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vel euismod
metus. Aenean molestie ligula ligula, imperdiet egestas tellus porttitor id.
Aliquam feugiat ullamcorper consequat. Suspendisse non libero scelerisque metus
sagittis placerat. Ut id tristique quam, ac tristique orci.
```{r}
plot(cars)
```
# Lorem ipsum 2
Cras id pretium enim, sed bibendum dui. Curabitur turpis lacus, ultricies vitae
sem vitae, interdum accumsan ligula. Donec quis ipsum pellentesque est ornare
pretium sit amet eu libero. Fusce eget ante sed leo vestibulum placerat.
但是,当我包含lang: es-MX
选项时,会出现错误。我只是将lang: es-MX
选项添加到标题(其他所有内容都相同):
---
title: "Lorem ipsum test"
lang: "es-MX"
output:
pdf_document:
toc: yes
html_notebook: default
abstract: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vel
euismod metus."
---
我在R Markdown选项卡中获得以下输出:
|...................... | 33%
ordinary text without R code
|........................................... | 67%
label: unnamed-chunk-1
processing file: test_file.Rmd
|.................................................................| 100%
ordinary text without R code
/usr/lib/rstudio/bin/pandoc/pandoc +RTS -K512m -RTS test_file.utf8.md --to latex
--from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash
--output test_file.tex --table-of-contents --toc-depth 2
--template /home/myuser/R/x86_64-redhat-linux-gnu-library/3.6/rmarkdown/rmd/latex/default-1.17.0.2.tex
--highlight-style tango --latex-engine pdflatex --variable graphics=yes
--variable 'geometry:margin=1in' --variable 'compact-title:yes'
output file: test_file.knit.md
! Package babel Error: Language definition file shorthands=off.ldf not found.
Error: Failed to compile test_file.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips.
See test_file.log for more info.
Ejecución interrumpida
检查日志文件(test_file.log
)我只看到以下警告和错误:
[...]
Package babel Warning: No hyphenation patterns were loaded for
(babel) the language `Spanish'
(babel) I will use the patterns loaded for \language=0 instead.
[...]
! Package babel Error: Language definition file shorthands=off.ldf not found.
See the babel package documentation for explanation.
Type H <return> for immediate help.
[...]
! ==> Fatal error occurred, no output PDF file produced!
现在,我发现.ldf
文件在哪里:/usr/share/texlive/texmf-dist/tex/generic/babel
,并且没有名为off.ldf
的文件。
所以,我的具体问题是:
如何从西班牙语的.Rmd文件 中获取我的PDF文件?
我还没有找到任何解决方案,所以...我将不胜感激。
根据Ralf Stubner在评论中的要求,这是生成的.tex文件中的“违规行”:
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[shorthands=off,main=spanish]{babel} %% <- This is it!
\else
\usepackage{polyglossia}
\setmainlanguage[]{spanish}
\fi
我在/home/myuser/R/x86_64-redhat-linux-gnu-library/3.6/rmarkdown/rmd/latex/default-1.17.0.2.tex
(第82和83行)找到了此“违规”行的模板:
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel}
%% ^^^^^^^^^^^^^^
%% This is where I think the problem is
我尝试注释掉这些行,并删除了“ shortnahds = off”位,但是错误不断出现。
这是日志文件(test_file.log)的标头,其中包括TeX和TexLive版本:
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013)
(format=pdflatex 2019.1.18) 21 AUG 2019 15:57
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**test_file.tex
(./test_file.tex
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for english, dumylang, nohyphenation, lo
aded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2007/10/19 v1.4h Standard LaTeX file (size option)
)
据此,TeX版本是3.1415926-2.5-1.40.14,TexLive版本是2013。我已经在Centos 7上同时使用yum
进行了安装。有趣的是,当使用LyX时,一切都可以正常工作。>
答案 0 :(得分:1)
该日志文件显示未加载任何西班牙连字符模式。我不确定使用TeXLive 2013会如何改变。我不建议在那儿花时间,而是安装最新的TeX发行版。 R中的tinytex::install_tinytex()
为您提供了一种简单的方法。我不确定默认情况下是否会包括西班牙语,但是如果不是这样,很容易解决。