pylatex Command
up vote
0
down vote
favorite
I'm using pylatex and I need to attach a logo in the header.
I want to use this latex example:
documentclass{article}
usepackage[tmargin=3cm,lmargin=3cm,rmargin=2cm]{geometry}
usepackage{geometry}
usepackage{graphicx}
usepackage{fancyhdr}
usepackage{xcolor}
pagestyle{fancy}
renewcommand{headrulewidth}{0pt}
rhead{begin{picture}(0,0) put(-500,0){includegraphics[width=5cm]{logo}} end{picture}}
begin{document}
SOMETHING
end{document}
I tried with this:
import pylatex as pyl
pyl.Command('rhead',
arguments=NoEscape(r'begin{picture}(0,0) put(0,0){includegraphics[width=4cm]{logo}} end{picture}')).dumps()
But is does not work. I do not get an error, it simly does not include it in the tex file. Thank you
macros pylatex
add a comment |
up vote
0
down vote
favorite
I'm using pylatex and I need to attach a logo in the header.
I want to use this latex example:
documentclass{article}
usepackage[tmargin=3cm,lmargin=3cm,rmargin=2cm]{geometry}
usepackage{geometry}
usepackage{graphicx}
usepackage{fancyhdr}
usepackage{xcolor}
pagestyle{fancy}
renewcommand{headrulewidth}{0pt}
rhead{begin{picture}(0,0) put(-500,0){includegraphics[width=5cm]{logo}} end{picture}}
begin{document}
SOMETHING
end{document}
I tried with this:
import pylatex as pyl
pyl.Command('rhead',
arguments=NoEscape(r'begin{picture}(0,0) put(0,0){includegraphics[width=4cm]{logo}} end{picture}')).dumps()
But is does not work. I do not get an error, it simly does not include it in the tex file. Thank you
macros pylatex
Please add a minimal working example (MWE) that illustrates your problem.
– Alessandro Cuttin
Dec 6 at 11:09
I edited the question
– scana
Dec 6 at 11:40
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm using pylatex and I need to attach a logo in the header.
I want to use this latex example:
documentclass{article}
usepackage[tmargin=3cm,lmargin=3cm,rmargin=2cm]{geometry}
usepackage{geometry}
usepackage{graphicx}
usepackage{fancyhdr}
usepackage{xcolor}
pagestyle{fancy}
renewcommand{headrulewidth}{0pt}
rhead{begin{picture}(0,0) put(-500,0){includegraphics[width=5cm]{logo}} end{picture}}
begin{document}
SOMETHING
end{document}
I tried with this:
import pylatex as pyl
pyl.Command('rhead',
arguments=NoEscape(r'begin{picture}(0,0) put(0,0){includegraphics[width=4cm]{logo}} end{picture}')).dumps()
But is does not work. I do not get an error, it simly does not include it in the tex file. Thank you
macros pylatex
I'm using pylatex and I need to attach a logo in the header.
I want to use this latex example:
documentclass{article}
usepackage[tmargin=3cm,lmargin=3cm,rmargin=2cm]{geometry}
usepackage{geometry}
usepackage{graphicx}
usepackage{fancyhdr}
usepackage{xcolor}
pagestyle{fancy}
renewcommand{headrulewidth}{0pt}
rhead{begin{picture}(0,0) put(-500,0){includegraphics[width=5cm]{logo}} end{picture}}
begin{document}
SOMETHING
end{document}
I tried with this:
import pylatex as pyl
pyl.Command('rhead',
arguments=NoEscape(r'begin{picture}(0,0) put(0,0){includegraphics[width=4cm]{logo}} end{picture}')).dumps()
But is does not work. I do not get an error, it simly does not include it in the tex file. Thank you
macros pylatex
macros pylatex
edited Dec 6 at 11:45
asked Dec 6 at 11:02
scana
32
32
Please add a minimal working example (MWE) that illustrates your problem.
– Alessandro Cuttin
Dec 6 at 11:09
I edited the question
– scana
Dec 6 at 11:40
add a comment |
Please add a minimal working example (MWE) that illustrates your problem.
– Alessandro Cuttin
Dec 6 at 11:09
I edited the question
– scana
Dec 6 at 11:40
Please add a minimal working example (MWE) that illustrates your problem.
– Alessandro Cuttin
Dec 6 at 11:09
Please add a minimal working example (MWE) that illustrates your problem.
– Alessandro Cuttin
Dec 6 at 11:09
I edited the question
– scana
Dec 6 at 11:40
I edited the question
– scana
Dec 6 at 11:40
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
The .dumps()
function is useful for debugging, because it allows you to see generated commands in the Python console. However, to include commands in the LaTeX document you should use .append
with the command itself as argument (and not the dump).
MWE:
import pylatex as pyl
doc = pyl.Document()
doc.packages.append(pyl.Package('graphicx'))
doc.packages.append(pyl.Package('fancyhdr'))
doc.preamble.append(pyl.Command('pagestyle', 'fancy'))
doc.preamble.append(pyl.Command('rhead',arguments=pyl.NoEscape(r'begin{picture}(0,0) put(0,0){includegraphics[width=4cm]{example-image}} end{picture}')))
doc.append('abc')
doc.generate_pdf('rheadtest', clean_tex=False)
Result (.tex
):
documentclass{article}%
usepackage[T1]{fontenc}%
usepackage[utf8]{inputenc}%
usepackage{lmodern}%
usepackage{textcomp}%
usepackage{lastpage}%
usepackage{graphicx}%
usepackage{fancyhdr}%
%
pagestyle{fancy}%
rhead{begin{picture}(0,0) put(0,0){includegraphics[width=4cm]{example-image}} end{picture}}%
%
begin{document}%
normalsize%
abc%
end{document}
Result (.pdf
):
doc.preamble!!! I've been looking for something like this for long. Thank you!
– scana
Dec 6 at 13:11
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',
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%2f463497%2fpylatex-command%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
The .dumps()
function is useful for debugging, because it allows you to see generated commands in the Python console. However, to include commands in the LaTeX document you should use .append
with the command itself as argument (and not the dump).
MWE:
import pylatex as pyl
doc = pyl.Document()
doc.packages.append(pyl.Package('graphicx'))
doc.packages.append(pyl.Package('fancyhdr'))
doc.preamble.append(pyl.Command('pagestyle', 'fancy'))
doc.preamble.append(pyl.Command('rhead',arguments=pyl.NoEscape(r'begin{picture}(0,0) put(0,0){includegraphics[width=4cm]{example-image}} end{picture}')))
doc.append('abc')
doc.generate_pdf('rheadtest', clean_tex=False)
Result (.tex
):
documentclass{article}%
usepackage[T1]{fontenc}%
usepackage[utf8]{inputenc}%
usepackage{lmodern}%
usepackage{textcomp}%
usepackage{lastpage}%
usepackage{graphicx}%
usepackage{fancyhdr}%
%
pagestyle{fancy}%
rhead{begin{picture}(0,0) put(0,0){includegraphics[width=4cm]{example-image}} end{picture}}%
%
begin{document}%
normalsize%
abc%
end{document}
Result (.pdf
):
doc.preamble!!! I've been looking for something like this for long. Thank you!
– scana
Dec 6 at 13:11
add a comment |
up vote
0
down vote
accepted
The .dumps()
function is useful for debugging, because it allows you to see generated commands in the Python console. However, to include commands in the LaTeX document you should use .append
with the command itself as argument (and not the dump).
MWE:
import pylatex as pyl
doc = pyl.Document()
doc.packages.append(pyl.Package('graphicx'))
doc.packages.append(pyl.Package('fancyhdr'))
doc.preamble.append(pyl.Command('pagestyle', 'fancy'))
doc.preamble.append(pyl.Command('rhead',arguments=pyl.NoEscape(r'begin{picture}(0,0) put(0,0){includegraphics[width=4cm]{example-image}} end{picture}')))
doc.append('abc')
doc.generate_pdf('rheadtest', clean_tex=False)
Result (.tex
):
documentclass{article}%
usepackage[T1]{fontenc}%
usepackage[utf8]{inputenc}%
usepackage{lmodern}%
usepackage{textcomp}%
usepackage{lastpage}%
usepackage{graphicx}%
usepackage{fancyhdr}%
%
pagestyle{fancy}%
rhead{begin{picture}(0,0) put(0,0){includegraphics[width=4cm]{example-image}} end{picture}}%
%
begin{document}%
normalsize%
abc%
end{document}
Result (.pdf
):
doc.preamble!!! I've been looking for something like this for long. Thank you!
– scana
Dec 6 at 13:11
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
The .dumps()
function is useful for debugging, because it allows you to see generated commands in the Python console. However, to include commands in the LaTeX document you should use .append
with the command itself as argument (and not the dump).
MWE:
import pylatex as pyl
doc = pyl.Document()
doc.packages.append(pyl.Package('graphicx'))
doc.packages.append(pyl.Package('fancyhdr'))
doc.preamble.append(pyl.Command('pagestyle', 'fancy'))
doc.preamble.append(pyl.Command('rhead',arguments=pyl.NoEscape(r'begin{picture}(0,0) put(0,0){includegraphics[width=4cm]{example-image}} end{picture}')))
doc.append('abc')
doc.generate_pdf('rheadtest', clean_tex=False)
Result (.tex
):
documentclass{article}%
usepackage[T1]{fontenc}%
usepackage[utf8]{inputenc}%
usepackage{lmodern}%
usepackage{textcomp}%
usepackage{lastpage}%
usepackage{graphicx}%
usepackage{fancyhdr}%
%
pagestyle{fancy}%
rhead{begin{picture}(0,0) put(0,0){includegraphics[width=4cm]{example-image}} end{picture}}%
%
begin{document}%
normalsize%
abc%
end{document}
Result (.pdf
):
The .dumps()
function is useful for debugging, because it allows you to see generated commands in the Python console. However, to include commands in the LaTeX document you should use .append
with the command itself as argument (and not the dump).
MWE:
import pylatex as pyl
doc = pyl.Document()
doc.packages.append(pyl.Package('graphicx'))
doc.packages.append(pyl.Package('fancyhdr'))
doc.preamble.append(pyl.Command('pagestyle', 'fancy'))
doc.preamble.append(pyl.Command('rhead',arguments=pyl.NoEscape(r'begin{picture}(0,0) put(0,0){includegraphics[width=4cm]{example-image}} end{picture}')))
doc.append('abc')
doc.generate_pdf('rheadtest', clean_tex=False)
Result (.tex
):
documentclass{article}%
usepackage[T1]{fontenc}%
usepackage[utf8]{inputenc}%
usepackage{lmodern}%
usepackage{textcomp}%
usepackage{lastpage}%
usepackage{graphicx}%
usepackage{fancyhdr}%
%
pagestyle{fancy}%
rhead{begin{picture}(0,0) put(0,0){includegraphics[width=4cm]{example-image}} end{picture}}%
%
begin{document}%
normalsize%
abc%
end{document}
Result (.pdf
):
answered Dec 6 at 12:02
Marijn
7,471636
7,471636
doc.preamble!!! I've been looking for something like this for long. Thank you!
– scana
Dec 6 at 13:11
add a comment |
doc.preamble!!! I've been looking for something like this for long. Thank you!
– scana
Dec 6 at 13:11
doc.preamble!!! I've been looking for something like this for long. Thank you!
– scana
Dec 6 at 13:11
doc.preamble!!! I've been looking for something like this for long. Thank you!
– scana
Dec 6 at 13:11
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f463497%2fpylatex-command%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
Please add a minimal working example (MWE) that illustrates your problem.
– Alessandro Cuttin
Dec 6 at 11:09
I edited the question
– scana
Dec 6 at 11:40