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
Add LaTeX citation handling to nbconvert #4090
Conversation
👍 |
@@ -30,31 +30,101 @@ class PDFPostProcessor(PostProcessorBase): | |||
How many times pdflatex will be called. | |||
""") | |||
|
|||
command = List(["pdflatex", "{filename}"], config=True, help=""" | |||
pdflatex_command = List(["pdflatex", "{filename}"], config=True, help=""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be 'latex_command', if it should change. It is not specific to pdflatex (I use xelatex, for example).
* Don't use lstrip/rstrip in that way. * Renaming things in the pdf postprocessor.
OK @minrk review comments are addressed. |
pass | ||
else: | ||
for child in node: | ||
_process_node_cite(child) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which branches of this block are exercised in your test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With my latest PR all branches are covered.
What are the chances, do you suppose, of supporting the citation syntax in other output formats (rst, etc.)? If we plan to do that, then |
Yes, I think that rename makes sense. There would need to be different On Sat, Aug 24, 2013 at 4:30 AM, Min RK notifications@github.com wrote:
Brian E. Granger |
* Rename parse_citation to citation2latex. * Add <p> block to test markdown.
OK I think all review comments have been addressed. |
Let's not merge this until we have a chance to talk at this weeks dev meeting. I have been looking at enabling MathJAx's equation numbering. In this mode, MathJax starts to parse more LaTeX syntax such as |
If it's a macro-style that expanded by codemirror why not, but adding extra syntax to markdown... you know the drill. |
Yes, it is more syntax we would be adding to Markdown, but if we want On Tue, Aug 27, 2013 at 11:45 PM, Matthias Bussonnier <
Brian E. Granger |
At the dev meeting this week we decided to go forward with this approach, merging. |
Add LaTeX citation handling to nbconvert
With respect to the issues in #4251 I wonder why the citation parsing uses lxml instead of simple regex? import re
s2 = u"Before <STRONG data-cite='granger'>(Granger, 2013)</strong> between <cite data-cite='foo'>(foo, 2012)</cite> behind"
re.sub("<(?P<tag>[a-z]*) data-cite='(?P<label>[^']*).*?/(?P=tag)>",'\\cite{\g<label>}',s2, flags=re.S|re.I) this gives u'Before \\cite{granger} between \\cite{foo} behind' it should be quite robust (the |
Because 'data-' is a general microdata format for html, and we'll probably use it for other things than citation. |
Parsing html with regex is almost always a bad idea. The problems arise On Wed, Sep 25, 2013 at 6:58 AM, Jakob Gager notifications@github.comwrote:
Brian E. Granger |
I totally agree that parsing a complete html structure with regex is an odd idea, however in the present case the data-cite microdata looks like just some sort of tag for a particular html container within a markdown text. This container is subsequently completely replaced by |
The On Wed, Sep 25, 2013 at 2:10 PM, Jakob Gager notifications@github.comwrote:
Brian E. Granger |
Sorry I'm still not convinced lxml is necessary 😕 |
Am now using this very nice feature to I think very nice effect. Posting a Q here because I wasn't sure that e.g. stackoverflow would have much wisdom on this. Q = how to change the colour of citations in the final pdf doc? At the moment mine are green, and as I've shifted to APA ('apalike') format rather than numbered references, there's lots of green words all over the text which are rather unsightly. Where should I look to change such a setting? Thanks, john |
The coloring of the citation links in the final pdf is done by the |
Add LaTeX citation handling to nbconvert
Is this still functional? I'm trying to use citations in IPython. I'm having some isssues. My notebook has one markdown cell,
My template looks like this:
And my bibliography has the section
My command line call is
The pdf is created, but all it contains is
Yes, bibliography.ipynb, bibliography.tplx, and bibliography.bib are all in the same folder. |
@bramtayl try opening an issue if we can track it and debug that there. I believe if should work. |
Ok, see #8760 |
This PR adds the ability for nbconvert to manage LaTeX citations. These are entered into the markdown cells using data attributes:
Which gets converted to the following in the LaTeX document:
\cite{granger}
We then run BibTeX. The user also has to override the bibliography block of the nbconvert template. See:
https://github.com/ipython/nbconvert-examples
For a full example.