-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.tex file has no document content #27
Comments
Ok, so this is the basic premise for the output formats:
So, firstly, try creating Test.ipynb (in a text editor) with the following text. Open it in Jupyter and run all the cells, then save it. (note you don't need to explicitly put {
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from ipypublish.scripts.ipynb_latex_setup import *"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for i in range(10):\n",
" print(i)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Chart 2."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.plot([1,2,3], [4,2,7]);"
]
}
],
"metadata": {
"hide_input": false,
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
} Now run \begin{document}
\title{Notebook}
\maketitle
\begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}1}]:} \PY{k+kn}{from} \PY{n+nn}{ipypublish}\PY{n+nn}{.}\PY{n+nn}{scripts}\PY{n+nn}{.}\PY{n+nn}{ipynb\PYZus{}latex\PYZus{}setup} \PY{k}{import} \PY{o}{*}
\end{Verbatim}
\begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}2}]:} \PY{k}{for} \PY{n}{i} \PY{o+ow}{in} \PY{n+nb}{range}\PY{p}{(}\PY{l+m+mi}{10}\PY{p}{)}\PY{p}{:}
\PY{n+nb}{print}\PY{p}{(}\PY{n}{i}\PY{p}{)}
\end{Verbatim}
\begin{Verbatim}[commandchars=\\\{\}]
0
1
2
3
4
5
6
7
8
9
\end{Verbatim}
Chart 2.
\begin{Verbatim}[commandchars=\\\{\}]
{\color{incolor}In [{\color{incolor}3}]:} \PY{n}{plt}\PY{o}{.}\PY{n}{plot}\PY{p}{(}\PY{p}{[}\PY{l+m+mi}{1}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{,}\PY{l+m+mi}{3}\PY{p}{]}\PY{p}{,} \PY{p}{[}\PY{l+m+mi}{4}\PY{p}{,}\PY{l+m+mi}{2}\PY{p}{,}\PY{l+m+mi}{7}\PY{p}{]}\PY{p}{)}\PY{p}{;}
\end{Verbatim}
\texttt{\color{outcolor}Out[{\color{outcolor}3}]:}\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{Test_files/output_3_0.pdf}
\end{center}
{ \hspace*{\fill} \\}
\end{document}
and run \begin{document}
Chart 2.
\end{document} |
Hello Chris, My brain got that the output would be out regardless (unless stated otherwise). Probably because that was what I was looking for. My brain workflow was to have a working version with the actual content and just skip the source code, as the target audience would not be interested in it. So the ipynb here would be a publishable (!? publishable !?) quasi-print quality, without any extras. But I totally get your point of having test code all around so you would focus on pushing what you do want to come out. Maybe an idea for your apreciation would be to have a 3rd template that would put the output automatically out, for the lazy people that don't want to mess with metadata cell by cell. Honestly, it would be easier to just use the one line solution with the I will check the metadata content again to force the output. It then should work. Sorry for the confusion. Thanks! |
Yeh, again thanks its good to get a user perspective. So yes, as you mention, there are two routes to go;
|
FYI, for your test notebook, try this :) {
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from ipypublish.scripts.ipynb_latex_setup import *"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for i in range(10):\n",
" print(i)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Chart 2\n",
"\n",
"with a nice reference to it \\cref{fig:chart2}."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"latex_doc": {
"figure": {
"caption": "the caption for chart 2",
"label": "fig:chart2",
"placement": "H"
}
}
},
"outputs": [],
"source": [
"plt.plot([1,2,3], [4,2,7]);"
]
}
],
"metadata": {
"celltoolbar": "Edit Metadata",
"hide_input": false,
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
} |
Hello Chris, Again, I will just check your instructions tomorrow and will close the ticket if it all goes as planned. Thanks for your support. |
haha cheers, yeh just keep the feedback coming :) My last top tip is, if you don't want all the extra files (produced by latexmk) in the converted folder, use Also, if you haven't noticed I've also created a new command
|
Moved the action points to #28, so I'll close this ticket now |
oops actually I'll wait for you to check it tomorrow ta |
Hello Chris, Sorry. It just went over my head. :( I thought I would be able to do it but it still escapes me. I believe I saw the solution in one way and you probably envision in a different one. To give you some context on what I would like to do, it is as follows:
There is more to the code, but you get the idea. From that, the output would be a repetition of some text and a chart. I could use the standard output, but it is quite simple. I did like the ipypublish latex style, but it leans more to an academic paper (which is why you created it, so I get it). As I said I tried to do it, but requires learning a lot and takes quite some time. I have to go back to my analysis and modelling. It would help me if you could digest it in smaller bits in a In any case, I have learned quite a few new things and tricks in trying to find a solution for my need. Also nice to see how people can help each other. So thanks for that too. Thanks! |
Ah you're so close!
So literally replace {
"latex_doc": {
"code": {},
"figure": {
"caption": "Figure caption.",
"label": "fig:flabel",
"placement": "H",
}
}
} Does that explain it? |
Hello Chris, The figure was working before. Do you have a trick for that one? Thanks |
haha, bit of a night owl. So just to confirm; the figure is working now and, if I put the gif (above) in the documentation, and altered the following line: For the |
Hello Chris, For me, the confusion was that I was looking for the output of the text as well. Nevertheless, you have done a great job. PS: Feel free to close the ticket if you want. |
ta |
Hello Chris,
Thanks for your help with the installation issue. All good now.
I am still having problems with content generation.
(1) With a simple notebook as described below, I only get the markdown. If using the
-f latex_standard_article
it works just aside some very minor formatting issues.(2) With a notebook of mine, it is not generating any
\document
content in the .tex file, only header/config details.There is something not happening on the
nbconvert
phase.Please let me know if you can see between the lines or if you need any specific information from my environment.
Thanks in advance.
1
Untitled.tex
Untitled.ipynb
2
$ nbpublish -pdf --pdf-debug notebook.ipynb
notebook.tex
nppub.log
conda / pip environments
The text was updated successfully, but these errors were encountered: