Compiling latex directly from R
I want to find a programmatic way of converting a .tex
latex document to pdf.
What I usually do, and this works in most cases, is to use:
tools::texi2dvi(latexfile, pdf = TRUE, clean = TRUE)
However, I now need to work with documents that contain Asian fonts (Chinese, Japanese and Korean). Searching on tex.stackexchange.com leads to advice to incude the following lines in the tex file:
usepackage{xeCJK}
setCJKmainfont{MS Mincho} % for rmfamily
This means I need to use xelatex
to build the pdf. I have tried variations on the following theme, none of which work.
shell(cmd="xelatex latexfile", mustWork=TRUE, translate=TRUE)
Question: How can I call xelatex
programmatically?
Additional information:
- I am on Windows 7, R2.13-1
xelatex
is installed on my machine and works fine if I call it any other way (including via the command line)- I am using StatET in Eclipse
xetex compiling r scripts
migrated from stackoverflow.com Sep 27 '11 at 11:30
This question came from our site for professional and enthusiast programmers.
|
show 1 more comment
I want to find a programmatic way of converting a .tex
latex document to pdf.
What I usually do, and this works in most cases, is to use:
tools::texi2dvi(latexfile, pdf = TRUE, clean = TRUE)
However, I now need to work with documents that contain Asian fonts (Chinese, Japanese and Korean). Searching on tex.stackexchange.com leads to advice to incude the following lines in the tex file:
usepackage{xeCJK}
setCJKmainfont{MS Mincho} % for rmfamily
This means I need to use xelatex
to build the pdf. I have tried variations on the following theme, none of which work.
shell(cmd="xelatex latexfile", mustWork=TRUE, translate=TRUE)
Question: How can I call xelatex
programmatically?
Additional information:
- I am on Windows 7, R2.13-1
xelatex
is installed on my machine and works fine if I call it any other way (including via the command line)- I am using StatET in Eclipse
xetex compiling r scripts
migrated from stackoverflow.com Sep 27 '11 at 11:30
This question came from our site for professional and enthusiast programmers.
1
but what happens when you run that shell() expression? what is the error?
– mdsumner
Sep 27 '11 at 8:46
If you are using MiKTeX, its texi2dvi executable has a--engine=ENGINE
option. So you could call it directly throughshell
– James
Sep 27 '11 at 11:24
I notice that this question was migrated from StackOverflow to tex.stackexchange. This makes no sense at all - my question is not a latex question, but an R programming question.
– Andrie
Sep 27 '11 at 12:30
I agree, but you should have asked it accurately in the first place . . . it's about control over spawning commands to the system from R (possibly via a 3rd party) on windows :)
– mdsumner
Sep 27 '11 at 12:37
@mdsumner Yes, it could have been more accurate. And I would have made it more accurate if I understood more about the problem. Thanks very much for your help!
– Andrie
Sep 27 '11 at 12:46
|
show 1 more comment
I want to find a programmatic way of converting a .tex
latex document to pdf.
What I usually do, and this works in most cases, is to use:
tools::texi2dvi(latexfile, pdf = TRUE, clean = TRUE)
However, I now need to work with documents that contain Asian fonts (Chinese, Japanese and Korean). Searching on tex.stackexchange.com leads to advice to incude the following lines in the tex file:
usepackage{xeCJK}
setCJKmainfont{MS Mincho} % for rmfamily
This means I need to use xelatex
to build the pdf. I have tried variations on the following theme, none of which work.
shell(cmd="xelatex latexfile", mustWork=TRUE, translate=TRUE)
Question: How can I call xelatex
programmatically?
Additional information:
- I am on Windows 7, R2.13-1
xelatex
is installed on my machine and works fine if I call it any other way (including via the command line)- I am using StatET in Eclipse
xetex compiling r scripts
I want to find a programmatic way of converting a .tex
latex document to pdf.
What I usually do, and this works in most cases, is to use:
tools::texi2dvi(latexfile, pdf = TRUE, clean = TRUE)
However, I now need to work with documents that contain Asian fonts (Chinese, Japanese and Korean). Searching on tex.stackexchange.com leads to advice to incude the following lines in the tex file:
usepackage{xeCJK}
setCJKmainfont{MS Mincho} % for rmfamily
This means I need to use xelatex
to build the pdf. I have tried variations on the following theme, none of which work.
shell(cmd="xelatex latexfile", mustWork=TRUE, translate=TRUE)
Question: How can I call xelatex
programmatically?
Additional information:
- I am on Windows 7, R2.13-1
xelatex
is installed on my machine and works fine if I call it any other way (including via the command line)- I am using StatET in Eclipse
xetex compiling r scripts
xetex compiling r scripts
edited Apr 13 '17 at 12:35
Community♦
1
1
asked Sep 27 '11 at 8:21
AndrieAndrie
176110
176110
migrated from stackoverflow.com Sep 27 '11 at 11:30
This question came from our site for professional and enthusiast programmers.
migrated from stackoverflow.com Sep 27 '11 at 11:30
This question came from our site for professional and enthusiast programmers.
1
but what happens when you run that shell() expression? what is the error?
– mdsumner
Sep 27 '11 at 8:46
If you are using MiKTeX, its texi2dvi executable has a--engine=ENGINE
option. So you could call it directly throughshell
– James
Sep 27 '11 at 11:24
I notice that this question was migrated from StackOverflow to tex.stackexchange. This makes no sense at all - my question is not a latex question, but an R programming question.
– Andrie
Sep 27 '11 at 12:30
I agree, but you should have asked it accurately in the first place . . . it's about control over spawning commands to the system from R (possibly via a 3rd party) on windows :)
– mdsumner
Sep 27 '11 at 12:37
@mdsumner Yes, it could have been more accurate. And I would have made it more accurate if I understood more about the problem. Thanks very much for your help!
– Andrie
Sep 27 '11 at 12:46
|
show 1 more comment
1
but what happens when you run that shell() expression? what is the error?
– mdsumner
Sep 27 '11 at 8:46
If you are using MiKTeX, its texi2dvi executable has a--engine=ENGINE
option. So you could call it directly throughshell
– James
Sep 27 '11 at 11:24
I notice that this question was migrated from StackOverflow to tex.stackexchange. This makes no sense at all - my question is not a latex question, but an R programming question.
– Andrie
Sep 27 '11 at 12:30
I agree, but you should have asked it accurately in the first place . . . it's about control over spawning commands to the system from R (possibly via a 3rd party) on windows :)
– mdsumner
Sep 27 '11 at 12:37
@mdsumner Yes, it could have been more accurate. And I would have made it more accurate if I understood more about the problem. Thanks very much for your help!
– Andrie
Sep 27 '11 at 12:46
1
1
but what happens when you run that shell() expression? what is the error?
– mdsumner
Sep 27 '11 at 8:46
but what happens when you run that shell() expression? what is the error?
– mdsumner
Sep 27 '11 at 8:46
If you are using MiKTeX, its texi2dvi executable has a
--engine=ENGINE
option. So you could call it directly through shell
– James
Sep 27 '11 at 11:24
If you are using MiKTeX, its texi2dvi executable has a
--engine=ENGINE
option. So you could call it directly through shell
– James
Sep 27 '11 at 11:24
I notice that this question was migrated from StackOverflow to tex.stackexchange. This makes no sense at all - my question is not a latex question, but an R programming question.
– Andrie
Sep 27 '11 at 12:30
I notice that this question was migrated from StackOverflow to tex.stackexchange. This makes no sense at all - my question is not a latex question, but an R programming question.
– Andrie
Sep 27 '11 at 12:30
I agree, but you should have asked it accurately in the first place . . . it's about control over spawning commands to the system from R (possibly via a 3rd party) on windows :)
– mdsumner
Sep 27 '11 at 12:37
I agree, but you should have asked it accurately in the first place . . . it's about control over spawning commands to the system from R (possibly via a 3rd party) on windows :)
– mdsumner
Sep 27 '11 at 12:37
@mdsumner Yes, it could have been more accurate. And I would have made it more accurate if I understood more about the problem. Thanks very much for your help!
– Andrie
Sep 27 '11 at 12:46
@mdsumner Yes, it could have been more accurate. And I would have made it more accurate if I understood more about the problem. Thanks very much for your help!
– Andrie
Sep 27 '11 at 12:46
|
show 1 more comment
3 Answers
3
active
oldest
votes
With some help from the helpful people at StackOverflow, two things emerged:
The correct way to call
xelatex
using a shell script from R is to remove the path from the full filename.
The reason that
xelatex
doesn't return control is because it enters interactive mode when detecting an error. To fix this, use the argument--mode=batchmode
:
shell(cmd=paste("xelatex --mode=batchmode", basename(latexfile)),
mustWork=TRUE, intern=TRUE, translate=TRUE)
add a comment |
You could also try texi2dvi
with an environment variableLATEX=xelatex
(not tested).
See the source code of tools::texi2dvi
(lines 145-147):
...
latex <- if (pdf)
Sys.getenv("PDFLATEX", "pdflatex")
else Sys.getenv("LATEX", "latex")
...
add a comment |
I eventually ended up with the following solution:
install.packages("tinytex")
require("tinytex")}
install_tinytex(force = TRUE)
tlmgr_install('montserrat')
xelatex('Report.tex')
This code install TinyTex, then it installs the font package montserrat with tlmgr_install function.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f29649%2fcompiling-latex-directly-from-r%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
With some help from the helpful people at StackOverflow, two things emerged:
The correct way to call
xelatex
using a shell script from R is to remove the path from the full filename.
The reason that
xelatex
doesn't return control is because it enters interactive mode when detecting an error. To fix this, use the argument--mode=batchmode
:
shell(cmd=paste("xelatex --mode=batchmode", basename(latexfile)),
mustWork=TRUE, intern=TRUE, translate=TRUE)
add a comment |
With some help from the helpful people at StackOverflow, two things emerged:
The correct way to call
xelatex
using a shell script from R is to remove the path from the full filename.
The reason that
xelatex
doesn't return control is because it enters interactive mode when detecting an error. To fix this, use the argument--mode=batchmode
:
shell(cmd=paste("xelatex --mode=batchmode", basename(latexfile)),
mustWork=TRUE, intern=TRUE, translate=TRUE)
add a comment |
With some help from the helpful people at StackOverflow, two things emerged:
The correct way to call
xelatex
using a shell script from R is to remove the path from the full filename.
The reason that
xelatex
doesn't return control is because it enters interactive mode when detecting an error. To fix this, use the argument--mode=batchmode
:
shell(cmd=paste("xelatex --mode=batchmode", basename(latexfile)),
mustWork=TRUE, intern=TRUE, translate=TRUE)
With some help from the helpful people at StackOverflow, two things emerged:
The correct way to call
xelatex
using a shell script from R is to remove the path from the full filename.
The reason that
xelatex
doesn't return control is because it enters interactive mode when detecting an error. To fix this, use the argument--mode=batchmode
:
shell(cmd=paste("xelatex --mode=batchmode", basename(latexfile)),
mustWork=TRUE, intern=TRUE, translate=TRUE)
edited Oct 6 '11 at 10:55
answered Sep 27 '11 at 12:45
AndrieAndrie
176110
176110
add a comment |
add a comment |
You could also try texi2dvi
with an environment variableLATEX=xelatex
(not tested).
See the source code of tools::texi2dvi
(lines 145-147):
...
latex <- if (pdf)
Sys.getenv("PDFLATEX", "pdflatex")
else Sys.getenv("LATEX", "latex")
...
add a comment |
You could also try texi2dvi
with an environment variableLATEX=xelatex
(not tested).
See the source code of tools::texi2dvi
(lines 145-147):
...
latex <- if (pdf)
Sys.getenv("PDFLATEX", "pdflatex")
else Sys.getenv("LATEX", "latex")
...
add a comment |
You could also try texi2dvi
with an environment variableLATEX=xelatex
(not tested).
See the source code of tools::texi2dvi
(lines 145-147):
...
latex <- if (pdf)
Sys.getenv("PDFLATEX", "pdflatex")
else Sys.getenv("LATEX", "latex")
...
You could also try texi2dvi
with an environment variableLATEX=xelatex
(not tested).
See the source code of tools::texi2dvi
(lines 145-147):
...
latex <- if (pdf)
Sys.getenv("PDFLATEX", "pdflatex")
else Sys.getenv("LATEX", "latex")
...
answered Sep 27 '11 at 12:50
rcsrcs
3,43321315
3,43321315
add a comment |
add a comment |
I eventually ended up with the following solution:
install.packages("tinytex")
require("tinytex")}
install_tinytex(force = TRUE)
tlmgr_install('montserrat')
xelatex('Report.tex')
This code install TinyTex, then it installs the font package montserrat with tlmgr_install function.
add a comment |
I eventually ended up with the following solution:
install.packages("tinytex")
require("tinytex")}
install_tinytex(force = TRUE)
tlmgr_install('montserrat')
xelatex('Report.tex')
This code install TinyTex, then it installs the font package montserrat with tlmgr_install function.
add a comment |
I eventually ended up with the following solution:
install.packages("tinytex")
require("tinytex")}
install_tinytex(force = TRUE)
tlmgr_install('montserrat')
xelatex('Report.tex')
This code install TinyTex, then it installs the font package montserrat with tlmgr_install function.
I eventually ended up with the following solution:
install.packages("tinytex")
require("tinytex")}
install_tinytex(force = TRUE)
tlmgr_install('montserrat')
xelatex('Report.tex')
This code install TinyTex, then it installs the font package montserrat with tlmgr_install function.
edited Feb 19 at 14:26
answered Feb 19 at 14:14
Stepan S. SushkoStepan S. Sushko
1012
1012
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f29649%2fcompiling-latex-directly-from-r%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
but what happens when you run that shell() expression? what is the error?
– mdsumner
Sep 27 '11 at 8:46
If you are using MiKTeX, its texi2dvi executable has a
--engine=ENGINE
option. So you could call it directly throughshell
– James
Sep 27 '11 at 11:24
I notice that this question was migrated from StackOverflow to tex.stackexchange. This makes no sense at all - my question is not a latex question, but an R programming question.
– Andrie
Sep 27 '11 at 12:30
I agree, but you should have asked it accurately in the first place . . . it's about control over spawning commands to the system from R (possibly via a 3rd party) on windows :)
– mdsumner
Sep 27 '11 at 12:37
@mdsumner Yes, it could have been more accurate. And I would have made it more accurate if I understood more about the problem. Thanks very much for your help!
– Andrie
Sep 27 '11 at 12:46