How can I use LaTeX from Python.What is a working python code snippet for escaping a string, so that it can...
Malformed Address '10.10.21.08/24', must be X.X.X.X/NN or
Why are electrically insulating heatsinks so rare? Is it just cost?
Add text to same line using sed
How do I deal with an unproductive colleague in a small company?
Approximately how much travel time was saved by the opening of the Suez Canal in 1869?
Alternative to sending password over mail?
If human space travel is limited by the G force vulnerability, is there a way to counter G forces?
Can an x86 CPU running in real mode be considered to be basically an 8086 CPU?
Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?
Watching something be written to a file live with tail
infared filters v nd
Perform and show arithmetic with LuaLaTeX
Roll the carpet
Modeling an IP Address
Convert two switches to a dual stack, and add outlet - possible here?
LWC SFDX source push error TypeError: LWC1009: decl.moveTo is not a function
Can I ask the recruiters in my resume to put the reason why I am rejected?
Horror movie about a virus at the prom; beginning and end are stylized as a cartoon
Do infinite dimensional systems make sense?
How can I prevent hyper evolved versions of regular creatures from wiping out their cousins?
Accidentally leaked the solution to an assignment, what to do now? (I'm the prof)
What's that red-plus icon near a text?
Can a Cauchy sequence converge for one metric while not converging for another?
What does "Puller Prush Person" mean?
How can I use LaTeX from Python.
What is a working python code snippet for escaping a string, so that it can be included in a tex file?Is it possible produce .djvu files from LaTeX directly?How to obfuscate my LaTeX document?How to use qpdf via latexmk?Dynamically use RTF-Code in latex-documentUtility to Strip Comments from LaTeX SourceResults that need LaTexLaTeX on the goWhat are some packages or methods that I can use to create JAWS-accessible LaTeX content?Latex “command examples” lookup / reference - from the command line?Pretty printing LaTeX source
I need to generate documents from a web application and would like to do this using the Python language and LaTeX, are there any tools that will help me?
Edit
This Application will be hosted on Linux, we can run any external commands using popen, there is currently no defined input document format, nor any storage format, but output to the end user should be PDF.
Edit 2
These documents will have complex tables, graphs, and require typeset equations - hence the reason to use LaTeX. We would also prefer not to use intermediate files such as xml->html->pdf
Ideally I would like something like pyTeX or plasTeX that could render directly to PDF.
tools
|
show 1 more comment
I need to generate documents from a web application and would like to do this using the Python language and LaTeX, are there any tools that will help me?
Edit
This Application will be hosted on Linux, we can run any external commands using popen, there is currently no defined input document format, nor any storage format, but output to the end user should be PDF.
Edit 2
These documents will have complex tables, graphs, and require typeset equations - hence the reason to use LaTeX. We would also prefer not to use intermediate files such as xml->html->pdf
Ideally I would like something like pyTeX or plasTeX that could render directly to PDF.
tools
Could you be a bit more specific about your requirements? In particular, what format will the documents be written in? What format would you like the output to be? Can you call external commands from your web application?
– Loop Space
Aug 3 '10 at 12:31
1
(responding to edit): So can you say: input format should be LaTeX and then callpdflatex
on the documents; somewhat in the spirit of what the arXiv does?
– Loop Space
Aug 3 '10 at 12:58
1
I would only go for LaTeX if you want more text (or math) than graphics. I say that, having done custom PDF output (tables, images, some text) for a desktop application.
– Jared Updike
Aug 3 '10 at 15:24
1
Do you really want python to do the conversion? What are the disadvantages, in your view, of simply callingpdflatex
as an external command?
– Loop Space
Aug 6 '10 at 12:25
If LaTeX and python are not strict requirements, you can look at ConTeXt lua documents which allows you to write directly compile lua programs to pdf (using luatex and the ConTeXt format).
– Aditya
Jun 27 '11 at 22:24
|
show 1 more comment
I need to generate documents from a web application and would like to do this using the Python language and LaTeX, are there any tools that will help me?
Edit
This Application will be hosted on Linux, we can run any external commands using popen, there is currently no defined input document format, nor any storage format, but output to the end user should be PDF.
Edit 2
These documents will have complex tables, graphs, and require typeset equations - hence the reason to use LaTeX. We would also prefer not to use intermediate files such as xml->html->pdf
Ideally I would like something like pyTeX or plasTeX that could render directly to PDF.
tools
I need to generate documents from a web application and would like to do this using the Python language and LaTeX, are there any tools that will help me?
Edit
This Application will be hosted on Linux, we can run any external commands using popen, there is currently no defined input document format, nor any storage format, but output to the end user should be PDF.
Edit 2
These documents will have complex tables, graphs, and require typeset equations - hence the reason to use LaTeX. We would also prefer not to use intermediate files such as xml->html->pdf
Ideally I would like something like pyTeX or plasTeX that could render directly to PDF.
tools
tools
edited Aug 6 '10 at 10:55
Frozenskys
asked Aug 3 '10 at 12:19
FrozenskysFrozenskys
371136
371136
Could you be a bit more specific about your requirements? In particular, what format will the documents be written in? What format would you like the output to be? Can you call external commands from your web application?
– Loop Space
Aug 3 '10 at 12:31
1
(responding to edit): So can you say: input format should be LaTeX and then callpdflatex
on the documents; somewhat in the spirit of what the arXiv does?
– Loop Space
Aug 3 '10 at 12:58
1
I would only go for LaTeX if you want more text (or math) than graphics. I say that, having done custom PDF output (tables, images, some text) for a desktop application.
– Jared Updike
Aug 3 '10 at 15:24
1
Do you really want python to do the conversion? What are the disadvantages, in your view, of simply callingpdflatex
as an external command?
– Loop Space
Aug 6 '10 at 12:25
If LaTeX and python are not strict requirements, you can look at ConTeXt lua documents which allows you to write directly compile lua programs to pdf (using luatex and the ConTeXt format).
– Aditya
Jun 27 '11 at 22:24
|
show 1 more comment
Could you be a bit more specific about your requirements? In particular, what format will the documents be written in? What format would you like the output to be? Can you call external commands from your web application?
– Loop Space
Aug 3 '10 at 12:31
1
(responding to edit): So can you say: input format should be LaTeX and then callpdflatex
on the documents; somewhat in the spirit of what the arXiv does?
– Loop Space
Aug 3 '10 at 12:58
1
I would only go for LaTeX if you want more text (or math) than graphics. I say that, having done custom PDF output (tables, images, some text) for a desktop application.
– Jared Updike
Aug 3 '10 at 15:24
1
Do you really want python to do the conversion? What are the disadvantages, in your view, of simply callingpdflatex
as an external command?
– Loop Space
Aug 6 '10 at 12:25
If LaTeX and python are not strict requirements, you can look at ConTeXt lua documents which allows you to write directly compile lua programs to pdf (using luatex and the ConTeXt format).
– Aditya
Jun 27 '11 at 22:24
Could you be a bit more specific about your requirements? In particular, what format will the documents be written in? What format would you like the output to be? Can you call external commands from your web application?
– Loop Space
Aug 3 '10 at 12:31
Could you be a bit more specific about your requirements? In particular, what format will the documents be written in? What format would you like the output to be? Can you call external commands from your web application?
– Loop Space
Aug 3 '10 at 12:31
1
1
(responding to edit): So can you say: input format should be LaTeX and then call
pdflatex
on the documents; somewhat in the spirit of what the arXiv does?– Loop Space
Aug 3 '10 at 12:58
(responding to edit): So can you say: input format should be LaTeX and then call
pdflatex
on the documents; somewhat in the spirit of what the arXiv does?– Loop Space
Aug 3 '10 at 12:58
1
1
I would only go for LaTeX if you want more text (or math) than graphics. I say that, having done custom PDF output (tables, images, some text) for a desktop application.
– Jared Updike
Aug 3 '10 at 15:24
I would only go for LaTeX if you want more text (or math) than graphics. I say that, having done custom PDF output (tables, images, some text) for a desktop application.
– Jared Updike
Aug 3 '10 at 15:24
1
1
Do you really want python to do the conversion? What are the disadvantages, in your view, of simply calling
pdflatex
as an external command?– Loop Space
Aug 6 '10 at 12:25
Do you really want python to do the conversion? What are the disadvantages, in your view, of simply calling
pdflatex
as an external command?– Loop Space
Aug 6 '10 at 12:25
If LaTeX and python are not strict requirements, you can look at ConTeXt lua documents which allows you to write directly compile lua programs to pdf (using luatex and the ConTeXt format).
– Aditya
Jun 27 '11 at 22:24
If LaTeX and python are not strict requirements, you can look at ConTeXt lua documents which allows you to write directly compile lua programs to pdf (using luatex and the ConTeXt format).
– Aditya
Jun 27 '11 at 22:24
|
show 1 more comment
12 Answers
12
active
oldest
votes
Recently I've written a library exactly for this purpose. It supports tables, plots, matrices and more.
https://github.com/JelteF/PyLaTeX
add a comment |
PyTeX is an Open Source project allowing to use TeX from within Python.
11
A little out of date as the last download available is 2005! :)
– Frozenskys
Aug 3 '10 at 12:49
add a comment |
This question should be closed because it actually has nothing to do with LaTeX and is more suited for StackOverflow. In any case the answer is that just like with HTML the best way is to use a templating system like Jinja2 and just output a LaTeX file. Once you have a LaTeX file simply use the subprocess module to run pdflatex (obviously you need it installed on your server). Don't forget to use the "-interaction nonstopmode" flag. I could go into technical details but again it's really more suited for a different site.
39
I appreciate why you think that. But as a third party observer, I can tell you that I just searched for python and latex and found this. I was happy about that!
– Jonathan Komar
Jul 3 '12 at 19:53
12
I think this is perfectly suited to the Tex stack.
– stuckintheshuck
Sep 16 '13 at 20:54
1
Great answer, I would just add a note that some chars should be escaped.
– neutrinus
Sep 12 '14 at 6:07
I think the question is well suited here.
– vy32
Sep 13 '18 at 11:08
add a comment |
Bit late for an answer, but would like to share my experience. I had a similar problem. Basically needed to get output from Python application in pdf form. Had a look at various alternatives
- Jinja2
- Reportlab
- Pollyreports
- As well as the options listed above
Eventually I settled on using Latex. Basically just wrote a small class that assembled my elements into a tex file and then ran pdflatex on the generated tex file. Other options had a lot of control, but tex already has great formatting predefined and I just needed a professional container for my figures and tables.
add a comment |
Depending on what you want to do, Sphinx may suit you. I think its the best Python-based tool for technical documentation, and it supports restructured text.
add a comment |
Is this what you're asking about? ( I used TeX to save code-space, but LaTeX is the same). If it is the what you're asking about, and you cut and paste this example, make sure the indents are correct after the paste.
#!/usr/bin/env python
import sys, os, os.path
filename = sys.argv[1]
opfile = sys.argv[1] + '.tex'
outfile = open(opfile, 'w')
pageAry = []
def a_tex_file(title):
global pageAry
pageAry.append('\vskip2emn\font\titlefont=cmr12 at 14.4ptn\font\default=cmr12n')
pageAry.append('\def\today{January 21, 2011}n')
pageAry.append('\centerline{\titlefont ' + title + '}n\vskip5ptn\vskip5pt\centerline{\default blahblahblah}n')
pageAry.append('n\bye')
return 1
a_tex_file("blunk")
for i in pageAry:
outfile.writelines(i)
outfile.close()
os.system('tex '+ opfile)
os.system('xdvi ' + filename + '.dvi & ')
Do you really need a global variable here?
– Mohan
Nov 24 '12 at 17:48
LOL. No, guess not. Don't know what I was thinking. Thanks for pointing that out.
– bev
Nov 24 '12 at 23:46
add a comment |
While I love LaTeX, you probably don't want or need TeX to solve your problem. Check out ReportLab Toolkit
add a comment |
Depending on exactly what you want to do, you may want to take a look at plasTeX. It's a python version of the TeX engine. It's not a true LaTeX interpreter, but if you have control over the input format of the documents then it could be possible to write them in such a manner that plasTeX can render them. At present, it renders the document to XHTML.
So if you wanted web-viewable copies, you could have it so that your documents were sufficiently simple that plasTeX can read them, then use plasTeX for XHTML-rendering and call pdflatex externally for PDF.
add a comment |
PyX is a useful package if you want graphs and charts.
add a comment |
If you want to convert a web page into a pdf, maybe the better way is using the python-pisa package, perform a direct conversion, I used it in a django projects for this purpose.
add a comment |
check latexmake. It allows easily to create your pdf files with python.
add a comment |
Where does the data for the PDF you want to generate come from? A database?
I ask because (despite being a big Python fan) I once used PHP to generate a latex file with data populated from a database (this was for a very small conference proceedings). It's a bit messy, but works reasonably well; you can easily intermingle PHP code which pulls from the database with latex source, in the same way that you can mix PHP with HTML. Then just compile the resulting latex file to get a PDF.
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%2f885%2fhow-can-i-use-latex-from-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
12 Answers
12
active
oldest
votes
12 Answers
12
active
oldest
votes
active
oldest
votes
active
oldest
votes
Recently I've written a library exactly for this purpose. It supports tables, plots, matrices and more.
https://github.com/JelteF/PyLaTeX
add a comment |
Recently I've written a library exactly for this purpose. It supports tables, plots, matrices and more.
https://github.com/JelteF/PyLaTeX
add a comment |
Recently I've written a library exactly for this purpose. It supports tables, plots, matrices and more.
https://github.com/JelteF/PyLaTeX
Recently I've written a library exactly for this purpose. It supports tables, plots, matrices and more.
https://github.com/JelteF/PyLaTeX
answered Jan 27 '14 at 11:35
JelteFJelteF
32125
32125
add a comment |
add a comment |
PyTeX is an Open Source project allowing to use TeX from within Python.
11
A little out of date as the last download available is 2005! :)
– Frozenskys
Aug 3 '10 at 12:49
add a comment |
PyTeX is an Open Source project allowing to use TeX from within Python.
11
A little out of date as the last download available is 2005! :)
– Frozenskys
Aug 3 '10 at 12:49
add a comment |
PyTeX is an Open Source project allowing to use TeX from within Python.
PyTeX is an Open Source project allowing to use TeX from within Python.
answered Aug 3 '10 at 12:28
Stefan Kottwitz♦Stefan Kottwitz
179k65572762
179k65572762
11
A little out of date as the last download available is 2005! :)
– Frozenskys
Aug 3 '10 at 12:49
add a comment |
11
A little out of date as the last download available is 2005! :)
– Frozenskys
Aug 3 '10 at 12:49
11
11
A little out of date as the last download available is 2005! :)
– Frozenskys
Aug 3 '10 at 12:49
A little out of date as the last download available is 2005! :)
– Frozenskys
Aug 3 '10 at 12:49
add a comment |
This question should be closed because it actually has nothing to do with LaTeX and is more suited for StackOverflow. In any case the answer is that just like with HTML the best way is to use a templating system like Jinja2 and just output a LaTeX file. Once you have a LaTeX file simply use the subprocess module to run pdflatex (obviously you need it installed on your server). Don't forget to use the "-interaction nonstopmode" flag. I could go into technical details but again it's really more suited for a different site.
39
I appreciate why you think that. But as a third party observer, I can tell you that I just searched for python and latex and found this. I was happy about that!
– Jonathan Komar
Jul 3 '12 at 19:53
12
I think this is perfectly suited to the Tex stack.
– stuckintheshuck
Sep 16 '13 at 20:54
1
Great answer, I would just add a note that some chars should be escaped.
– neutrinus
Sep 12 '14 at 6:07
I think the question is well suited here.
– vy32
Sep 13 '18 at 11:08
add a comment |
This question should be closed because it actually has nothing to do with LaTeX and is more suited for StackOverflow. In any case the answer is that just like with HTML the best way is to use a templating system like Jinja2 and just output a LaTeX file. Once you have a LaTeX file simply use the subprocess module to run pdflatex (obviously you need it installed on your server). Don't forget to use the "-interaction nonstopmode" flag. I could go into technical details but again it's really more suited for a different site.
39
I appreciate why you think that. But as a third party observer, I can tell you that I just searched for python and latex and found this. I was happy about that!
– Jonathan Komar
Jul 3 '12 at 19:53
12
I think this is perfectly suited to the Tex stack.
– stuckintheshuck
Sep 16 '13 at 20:54
1
Great answer, I would just add a note that some chars should be escaped.
– neutrinus
Sep 12 '14 at 6:07
I think the question is well suited here.
– vy32
Sep 13 '18 at 11:08
add a comment |
This question should be closed because it actually has nothing to do with LaTeX and is more suited for StackOverflow. In any case the answer is that just like with HTML the best way is to use a templating system like Jinja2 and just output a LaTeX file. Once you have a LaTeX file simply use the subprocess module to run pdflatex (obviously you need it installed on your server). Don't forget to use the "-interaction nonstopmode" flag. I could go into technical details but again it's really more suited for a different site.
This question should be closed because it actually has nothing to do with LaTeX and is more suited for StackOverflow. In any case the answer is that just like with HTML the best way is to use a templating system like Jinja2 and just output a LaTeX file. Once you have a LaTeX file simply use the subprocess module to run pdflatex (obviously you need it installed on your server). Don't forget to use the "-interaction nonstopmode" flag. I could go into technical details but again it's really more suited for a different site.
answered Aug 5 '10 at 19:59
user573
39
I appreciate why you think that. But as a third party observer, I can tell you that I just searched for python and latex and found this. I was happy about that!
– Jonathan Komar
Jul 3 '12 at 19:53
12
I think this is perfectly suited to the Tex stack.
– stuckintheshuck
Sep 16 '13 at 20:54
1
Great answer, I would just add a note that some chars should be escaped.
– neutrinus
Sep 12 '14 at 6:07
I think the question is well suited here.
– vy32
Sep 13 '18 at 11:08
add a comment |
39
I appreciate why you think that. But as a third party observer, I can tell you that I just searched for python and latex and found this. I was happy about that!
– Jonathan Komar
Jul 3 '12 at 19:53
12
I think this is perfectly suited to the Tex stack.
– stuckintheshuck
Sep 16 '13 at 20:54
1
Great answer, I would just add a note that some chars should be escaped.
– neutrinus
Sep 12 '14 at 6:07
I think the question is well suited here.
– vy32
Sep 13 '18 at 11:08
39
39
I appreciate why you think that. But as a third party observer, I can tell you that I just searched for python and latex and found this. I was happy about that!
– Jonathan Komar
Jul 3 '12 at 19:53
I appreciate why you think that. But as a third party observer, I can tell you that I just searched for python and latex and found this. I was happy about that!
– Jonathan Komar
Jul 3 '12 at 19:53
12
12
I think this is perfectly suited to the Tex stack.
– stuckintheshuck
Sep 16 '13 at 20:54
I think this is perfectly suited to the Tex stack.
– stuckintheshuck
Sep 16 '13 at 20:54
1
1
Great answer, I would just add a note that some chars should be escaped.
– neutrinus
Sep 12 '14 at 6:07
Great answer, I would just add a note that some chars should be escaped.
– neutrinus
Sep 12 '14 at 6:07
I think the question is well suited here.
– vy32
Sep 13 '18 at 11:08
I think the question is well suited here.
– vy32
Sep 13 '18 at 11:08
add a comment |
Bit late for an answer, but would like to share my experience. I had a similar problem. Basically needed to get output from Python application in pdf form. Had a look at various alternatives
- Jinja2
- Reportlab
- Pollyreports
- As well as the options listed above
Eventually I settled on using Latex. Basically just wrote a small class that assembled my elements into a tex file and then ran pdflatex on the generated tex file. Other options had a lot of control, but tex already has great formatting predefined and I just needed a professional container for my figures and tables.
add a comment |
Bit late for an answer, but would like to share my experience. I had a similar problem. Basically needed to get output from Python application in pdf form. Had a look at various alternatives
- Jinja2
- Reportlab
- Pollyreports
- As well as the options listed above
Eventually I settled on using Latex. Basically just wrote a small class that assembled my elements into a tex file and then ran pdflatex on the generated tex file. Other options had a lot of control, but tex already has great formatting predefined and I just needed a professional container for my figures and tables.
add a comment |
Bit late for an answer, but would like to share my experience. I had a similar problem. Basically needed to get output from Python application in pdf form. Had a look at various alternatives
- Jinja2
- Reportlab
- Pollyreports
- As well as the options listed above
Eventually I settled on using Latex. Basically just wrote a small class that assembled my elements into a tex file and then ran pdflatex on the generated tex file. Other options had a lot of control, but tex already has great formatting predefined and I just needed a professional container for my figures and tables.
Bit late for an answer, but would like to share my experience. I had a similar problem. Basically needed to get output from Python application in pdf form. Had a look at various alternatives
- Jinja2
- Reportlab
- Pollyreports
- As well as the options listed above
Eventually I settled on using Latex. Basically just wrote a small class that assembled my elements into a tex file and then ran pdflatex on the generated tex file. Other options had a lot of control, but tex already has great formatting predefined and I just needed a professional container for my figures and tables.
edited 9 hours ago
user7427029
1006
1006
answered May 26 '13 at 19:48
JoopJoop
22337
22337
add a comment |
add a comment |
Depending on what you want to do, Sphinx may suit you. I think its the best Python-based tool for technical documentation, and it supports restructured text.
add a comment |
Depending on what you want to do, Sphinx may suit you. I think its the best Python-based tool for technical documentation, and it supports restructured text.
add a comment |
Depending on what you want to do, Sphinx may suit you. I think its the best Python-based tool for technical documentation, and it supports restructured text.
Depending on what you want to do, Sphinx may suit you. I think its the best Python-based tool for technical documentation, and it supports restructured text.
answered Aug 5 '10 at 5:01
Jonathan FineJonathan Fine
1,6831213
1,6831213
add a comment |
add a comment |
Is this what you're asking about? ( I used TeX to save code-space, but LaTeX is the same). If it is the what you're asking about, and you cut and paste this example, make sure the indents are correct after the paste.
#!/usr/bin/env python
import sys, os, os.path
filename = sys.argv[1]
opfile = sys.argv[1] + '.tex'
outfile = open(opfile, 'w')
pageAry = []
def a_tex_file(title):
global pageAry
pageAry.append('\vskip2emn\font\titlefont=cmr12 at 14.4ptn\font\default=cmr12n')
pageAry.append('\def\today{January 21, 2011}n')
pageAry.append('\centerline{\titlefont ' + title + '}n\vskip5ptn\vskip5pt\centerline{\default blahblahblah}n')
pageAry.append('n\bye')
return 1
a_tex_file("blunk")
for i in pageAry:
outfile.writelines(i)
outfile.close()
os.system('tex '+ opfile)
os.system('xdvi ' + filename + '.dvi & ')
Do you really need a global variable here?
– Mohan
Nov 24 '12 at 17:48
LOL. No, guess not. Don't know what I was thinking. Thanks for pointing that out.
– bev
Nov 24 '12 at 23:46
add a comment |
Is this what you're asking about? ( I used TeX to save code-space, but LaTeX is the same). If it is the what you're asking about, and you cut and paste this example, make sure the indents are correct after the paste.
#!/usr/bin/env python
import sys, os, os.path
filename = sys.argv[1]
opfile = sys.argv[1] + '.tex'
outfile = open(opfile, 'w')
pageAry = []
def a_tex_file(title):
global pageAry
pageAry.append('\vskip2emn\font\titlefont=cmr12 at 14.4ptn\font\default=cmr12n')
pageAry.append('\def\today{January 21, 2011}n')
pageAry.append('\centerline{\titlefont ' + title + '}n\vskip5ptn\vskip5pt\centerline{\default blahblahblah}n')
pageAry.append('n\bye')
return 1
a_tex_file("blunk")
for i in pageAry:
outfile.writelines(i)
outfile.close()
os.system('tex '+ opfile)
os.system('xdvi ' + filename + '.dvi & ')
Do you really need a global variable here?
– Mohan
Nov 24 '12 at 17:48
LOL. No, guess not. Don't know what I was thinking. Thanks for pointing that out.
– bev
Nov 24 '12 at 23:46
add a comment |
Is this what you're asking about? ( I used TeX to save code-space, but LaTeX is the same). If it is the what you're asking about, and you cut and paste this example, make sure the indents are correct after the paste.
#!/usr/bin/env python
import sys, os, os.path
filename = sys.argv[1]
opfile = sys.argv[1] + '.tex'
outfile = open(opfile, 'w')
pageAry = []
def a_tex_file(title):
global pageAry
pageAry.append('\vskip2emn\font\titlefont=cmr12 at 14.4ptn\font\default=cmr12n')
pageAry.append('\def\today{January 21, 2011}n')
pageAry.append('\centerline{\titlefont ' + title + '}n\vskip5ptn\vskip5pt\centerline{\default blahblahblah}n')
pageAry.append('n\bye')
return 1
a_tex_file("blunk")
for i in pageAry:
outfile.writelines(i)
outfile.close()
os.system('tex '+ opfile)
os.system('xdvi ' + filename + '.dvi & ')
Is this what you're asking about? ( I used TeX to save code-space, but LaTeX is the same). If it is the what you're asking about, and you cut and paste this example, make sure the indents are correct after the paste.
#!/usr/bin/env python
import sys, os, os.path
filename = sys.argv[1]
opfile = sys.argv[1] + '.tex'
outfile = open(opfile, 'w')
pageAry = []
def a_tex_file(title):
global pageAry
pageAry.append('\vskip2emn\font\titlefont=cmr12 at 14.4ptn\font\default=cmr12n')
pageAry.append('\def\today{January 21, 2011}n')
pageAry.append('\centerline{\titlefont ' + title + '}n\vskip5ptn\vskip5pt\centerline{\default blahblahblah}n')
pageAry.append('n\bye')
return 1
a_tex_file("blunk")
for i in pageAry:
outfile.writelines(i)
outfile.close()
os.system('tex '+ opfile)
os.system('xdvi ' + filename + '.dvi & ')
edited Sep 27 '11 at 22:28
doncherry
35.3k23137209
35.3k23137209
answered Jan 21 '11 at 10:16
bevbev
1,2351316
1,2351316
Do you really need a global variable here?
– Mohan
Nov 24 '12 at 17:48
LOL. No, guess not. Don't know what I was thinking. Thanks for pointing that out.
– bev
Nov 24 '12 at 23:46
add a comment |
Do you really need a global variable here?
– Mohan
Nov 24 '12 at 17:48
LOL. No, guess not. Don't know what I was thinking. Thanks for pointing that out.
– bev
Nov 24 '12 at 23:46
Do you really need a global variable here?
– Mohan
Nov 24 '12 at 17:48
Do you really need a global variable here?
– Mohan
Nov 24 '12 at 17:48
LOL. No, guess not. Don't know what I was thinking. Thanks for pointing that out.
– bev
Nov 24 '12 at 23:46
LOL. No, guess not. Don't know what I was thinking. Thanks for pointing that out.
– bev
Nov 24 '12 at 23:46
add a comment |
While I love LaTeX, you probably don't want or need TeX to solve your problem. Check out ReportLab Toolkit
add a comment |
While I love LaTeX, you probably don't want or need TeX to solve your problem. Check out ReportLab Toolkit
add a comment |
While I love LaTeX, you probably don't want or need TeX to solve your problem. Check out ReportLab Toolkit
While I love LaTeX, you probably don't want or need TeX to solve your problem. Check out ReportLab Toolkit
answered Aug 3 '10 at 14:15
ptmanptman
1612
1612
add a comment |
add a comment |
Depending on exactly what you want to do, you may want to take a look at plasTeX. It's a python version of the TeX engine. It's not a true LaTeX interpreter, but if you have control over the input format of the documents then it could be possible to write them in such a manner that plasTeX can render them. At present, it renders the document to XHTML.
So if you wanted web-viewable copies, you could have it so that your documents were sufficiently simple that plasTeX can read them, then use plasTeX for XHTML-rendering and call pdflatex externally for PDF.
add a comment |
Depending on exactly what you want to do, you may want to take a look at plasTeX. It's a python version of the TeX engine. It's not a true LaTeX interpreter, but if you have control over the input format of the documents then it could be possible to write them in such a manner that plasTeX can render them. At present, it renders the document to XHTML.
So if you wanted web-viewable copies, you could have it so that your documents were sufficiently simple that plasTeX can read them, then use plasTeX for XHTML-rendering and call pdflatex externally for PDF.
add a comment |
Depending on exactly what you want to do, you may want to take a look at plasTeX. It's a python version of the TeX engine. It's not a true LaTeX interpreter, but if you have control over the input format of the documents then it could be possible to write them in such a manner that plasTeX can render them. At present, it renders the document to XHTML.
So if you wanted web-viewable copies, you could have it so that your documents were sufficiently simple that plasTeX can read them, then use plasTeX for XHTML-rendering and call pdflatex externally for PDF.
Depending on exactly what you want to do, you may want to take a look at plasTeX. It's a python version of the TeX engine. It's not a true LaTeX interpreter, but if you have control over the input format of the documents then it could be possible to write them in such a manner that plasTeX can render them. At present, it renders the document to XHTML.
So if you wanted web-viewable copies, you could have it so that your documents were sufficiently simple that plasTeX can read them, then use plasTeX for XHTML-rendering and call pdflatex externally for PDF.
answered Aug 5 '10 at 7:21
Loop SpaceLoop Space
113k30309610
113k30309610
add a comment |
add a comment |
PyX is a useful package if you want graphs and charts.
add a comment |
PyX is a useful package if you want graphs and charts.
add a comment |
PyX is a useful package if you want graphs and charts.
PyX is a useful package if you want graphs and charts.
answered Aug 3 '10 at 15:22
Jared UpdikeJared Updike
568158
568158
add a comment |
add a comment |
If you want to convert a web page into a pdf, maybe the better way is using the python-pisa package, perform a direct conversion, I used it in a django projects for this purpose.
add a comment |
If you want to convert a web page into a pdf, maybe the better way is using the python-pisa package, perform a direct conversion, I used it in a django projects for this purpose.
add a comment |
If you want to convert a web page into a pdf, maybe the better way is using the python-pisa package, perform a direct conversion, I used it in a django projects for this purpose.
If you want to convert a web page into a pdf, maybe the better way is using the python-pisa package, perform a direct conversion, I used it in a django projects for this purpose.
answered Feb 27 '14 at 13:18
Evys Ancede GallardoEvys Ancede Gallardo
311
311
add a comment |
add a comment |
check latexmake. It allows easily to create your pdf files with python.
add a comment |
check latexmake. It allows easily to create your pdf files with python.
add a comment |
check latexmake. It allows easily to create your pdf files with python.
check latexmake. It allows easily to create your pdf files with python.
edited Dec 22 '18 at 14:22
answered Jun 27 '11 at 22:05
pmav99pmav99
3,38822851
3,38822851
add a comment |
add a comment |
Where does the data for the PDF you want to generate come from? A database?
I ask because (despite being a big Python fan) I once used PHP to generate a latex file with data populated from a database (this was for a very small conference proceedings). It's a bit messy, but works reasonably well; you can easily intermingle PHP code which pulls from the database with latex source, in the same way that you can mix PHP with HTML. Then just compile the resulting latex file to get a PDF.
add a comment |
Where does the data for the PDF you want to generate come from? A database?
I ask because (despite being a big Python fan) I once used PHP to generate a latex file with data populated from a database (this was for a very small conference proceedings). It's a bit messy, but works reasonably well; you can easily intermingle PHP code which pulls from the database with latex source, in the same way that you can mix PHP with HTML. Then just compile the resulting latex file to get a PDF.
add a comment |
Where does the data for the PDF you want to generate come from? A database?
I ask because (despite being a big Python fan) I once used PHP to generate a latex file with data populated from a database (this was for a very small conference proceedings). It's a bit messy, but works reasonably well; you can easily intermingle PHP code which pulls from the database with latex source, in the same way that you can mix PHP with HTML. Then just compile the resulting latex file to get a PDF.
Where does the data for the PDF you want to generate come from? A database?
I ask because (despite being a big Python fan) I once used PHP to generate a latex file with data populated from a database (this was for a very small conference proceedings). It's a bit messy, but works reasonably well; you can easily intermingle PHP code which pulls from the database with latex source, in the same way that you can mix PHP with HTML. Then just compile the resulting latex file to get a PDF.
answered Aug 5 '10 at 3:26
Neil OlverNeil Olver
2,98441818
2,98441818
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%2f885%2fhow-can-i-use-latex-from-python%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
Could you be a bit more specific about your requirements? In particular, what format will the documents be written in? What format would you like the output to be? Can you call external commands from your web application?
– Loop Space
Aug 3 '10 at 12:31
1
(responding to edit): So can you say: input format should be LaTeX and then call
pdflatex
on the documents; somewhat in the spirit of what the arXiv does?– Loop Space
Aug 3 '10 at 12:58
1
I would only go for LaTeX if you want more text (or math) than graphics. I say that, having done custom PDF output (tables, images, some text) for a desktop application.
– Jared Updike
Aug 3 '10 at 15:24
1
Do you really want python to do the conversion? What are the disadvantages, in your view, of simply calling
pdflatex
as an external command?– Loop Space
Aug 6 '10 at 12:25
If LaTeX and python are not strict requirements, you can look at ConTeXt lua documents which allows you to write directly compile lua programs to pdf (using luatex and the ConTeXt format).
– Aditya
Jun 27 '11 at 22:24