Get Latex structure of a document - latex

I'm looking for a way to get a generic structure (as JSON) for a latex document:
Directly from texlive
As a Python module (For example: https://pylatexenc.readthedocs.io/en/latest/latexwalker/)
As a Node module (For example: https://www.npmjs.com/package/latex-ast-parser)
Is there a preferred way to do that to be sure to support most of things of Latex?
Thanks for your help,
Thierry

Related

use scholar.google.com reference in latex file

When I use scholar.google.com to get the full reference code (BibTeX) such as
#article{li2018design,
title={Design and implementation of building structure monitoring system based on radio frequency identification (RFID)},
author={Li, Hongwei and Ren, Yilei},
journal={International Journal of RF Technologies},
volume={9},
number={1-2},
pages={37--49},
year={2018},
publisher={IOS Press}
}
Then go to the journal template file, I want to copy the reference from scholar.google.com and paste it into the LaTex journal template file without doing any modification.
The template file looks like this:
Unfortunately, the paste in the template file does NOT work.
Here is the error message:
Can you assist of how to do it and make the file work correctly?
The format given by Google scholar has to be used when you compile, in order, with
Latex (or PDFLatex)
Bibtex
Latex (or PDFLatex)
Latex (or PDFLatex)
where you store the entries of your bibliography in a separate file named <mydoc>.bib.
You are simply using \thebibliography environment, which allows you to write \bibitems, which is a simpler approach (even if I suggest to use it when you have a small number of bibliography entries). If you have to use this latter approach, you have to rewrite the reference retrieved in Google scholar in the format needed by your document.
Have a look here: it explains very well the differences.

knitr/rmarkdown/Latex: How to cross-reference figures and tables in 2 different pdf files?

I'm trying to write a scientific article and the associated supplementary materials entirely in RStudio with rmarkdown.
It seems clear that book down is the way to go to cross-reference between files (https://stackoverflow.com/a/38884378/576684), but I also would like to be able to reference figures produced in one pdf in the other pdf.
Although my latex has got quite rusty with time, I imagine it could be achieved as follows:
compile the article tex and SuppMat tex a first time using rmarkdown::render()
compile these tex files from the command line in order to keep the corresponding .aux file with their references (missing references won't be resolved at this time)
recompile the 2 tex files from the command line another time where all references should now be resolved
Is it a reasonable way to do it? am I overlooking something simpler?
In any case, it requires:
a different numbering of figures in each pdf file (covered by https://stackoverflow.com/a/51337664/576684)
to prevent rmarkdown from trashing the .aux files (it seems that pandoc doesn't allow this, hence the need to create the aux file using standalone latex)
to tell latex to use the additional .aux file if it is found (probably using header-includes: in the YAML header). how can I achieve that?
Thank you very much for your help!
It turns out that the xr package is one way to go: https://texblog.org/2016/08/23/adding-references-from-an-external-file/
so this works from R:
rmarkdown::render("myarticle_ms.Rmd",
bookdown::pdf_book(base_format=rticles::plos_article),
clean=FALSE)
rmarkdown::render("myarticle_SM.Rmd",
bookdown::pdf_book(base_format=rticles::plos_article),
clean=FALSE)
tinytex::pdflatex("myarticle_ms.tex", clean=FALSE)
tinytex::pdflatex("myarticle_SM.tex", clean=FALSE)
tinytex::pdflatex("myarticle_ms.tex")
tinytex::pdflatex("myarticle_SM.tex")
with the following in the YAML header of myarticle_ms.Rmd (and the corresponding one the SuppMat file header):
header-includes:
\usepackage{xr} \externaldocument{myarticle_SM}
Hope it makes life easier for a few others :)

Jinja2 templates for latex - tutorials

I was wondering if someone can point me to the tutorials on how to create custom Jinja2 templates for LaTeX, so that I can use it in with nbconvert to convert Jupyter notebook into LaTeX?
Unfortunately that is highly undocumented. I would suggest asking on the mailing list or directly open an issue on GitHub (jupyter/nbconvert repo)
The normal template informations you find will work with one difference that you need to replace the template extension from .tpl to .tplxand replace the jinja delimiters: {% to ((* for blocks , {{ to ((( for variable interpolations and {# to ((= for comments + all the symetric closing markers. The reasoning is that latex uses { heavily and you want to avoid conflict.
Otherwise there is close to no difference between latex and non-latex templates.
I found this tutorial from the IPython/Jupyter Workshop at the NGCM Summer Academy (official jupyter github).

Individual function docs in LaTeX using doxygen

I'm writing a manual of sorts in LaTeX for some software. I'm constrained to use the article class. I must include docs of individual c++ classes in the manual. I'm looking at doxygen for this, but I've never used doxygen (if there's a better way, let me know).
I can get doxygen to produce a nice LaTeX (--> pdf) file of my entire project. But what I'd like to do is somehow extract the LaTeX source for each class and drop it into my LaTeX manual source at the appropriate place.
I've tried putting all the preamble stuff from refman.tex (generated by doxygen) in my preamble, and then later in the document using \input to include the tex file of an individual class. After cleaning up a few conflicts, I get to one that I don't know how to get past. The doxygen-generated doxygen.sty file makes reference to \chaptermark, but I believe that this is a macro defined in the book class.
So 1.) Am I going about this all the wrong way? 2.)Is it possible to force Doxygen to produce code in the article class? 3.) Anything else?
-garyp
You can make doxygen produce a document that uses the article document class by setting COMPACT_LATEX to YES in your doxygen config file.

LaTeX Global declarations

So, I'm self-taught in the art of LaTeX, which means there are some really simple things that I just haven't ever figured out. One thing that I've always wanted to know was how to add to a sort of global preamble where I can add custom declarations and the like that will automatically be included when I render a document. Any thoughts?
You can create your own package to load with \usepackage. In it you can declare functions that you use commonly. If it is in the directory with your source it can be included directly, otherwise if you want to use it for all your documents, put in in your latex distibution folder and run texhash so that the compiler can find it.
Directions can be found in the LaTeX Wikibook or other places I'm sure. I also was a self taught LaTeXer and the Wikibook taught me most of what I needed, along with the short-math-guide and a few package manuals (especially for TikZ/PGF and Beamer).

Resources