pandoc LaTex add CSS to create PDF - latex

I have the a markdown file and a css file in the same folder at same level.
I want to use the css in creaing the PDF output.
I tired the following command
pandoc -c pandoc.css input.md -o output.pdf
The styles did not apply.
what am I missing here?

By default, pandoc uses LaTeX under the hood to generate the PDF, which doesn't understand CSS.
However, if installed, pandoc can also use wkhtmltopdf which does undertand CSS. To generate a PDF with wkhtmltopdf, include -t html5, e.g. pandoc -t html5 input.md -o output.pdf.
To include an external CSS file, either use --css mystyles.css or use markdown document metadata like:
---
css: mystyles.css
---
my document body

Related

Markdown and doxygen linking back to a file

Doxygen now allows to link md files to other md files with regular markdown syntax:
How do I link between markdown documents in doxygen?
I have the following file structure:
MyDir/README.md
MyDir/Docs/other.md
Linking from README.md to other.md is straigforward:
[My link](Docs/other.md)
However linking from other to Readme is not working:
[My back link](README.md)
Since doxygen generates its links relative to where it is run, and I am running doxygen on MyDir, that should be the correct relative path. I also tried
[My back link](../README.md)
Just in case, but no luck.

Pandoc: does not include input files

I have a LaTeX file that refers to many other single files. Those files are included/referenced by
\input{somefolder/somefile}
Context: Now I'm trying to import the LaTeX to Adobe Indesign by converting it to Docx first and then to Indesign using Pandoc.
Problem: But somehow Pandoc is generating the output just from the main tex file (the entry point) and does not follow the inputs. What am I doing wrong?
pandoc main.tex -t docx -o main.docx
Newer versions of pandoc seem to support the \input{} construct (tried on pandoc 1.19.2.1).
Also, why go via docx? Try:
pandoc input.tex -o output.icml
and place the generated ICML in your InDesign document.

How to add watermark to the doxygen generated PDF file

I am generating the PDF file using doxygen on a Linux system.
I am using "make" in the latex folder. This generates the refman.pdf. I want to add a "INTERNAL ONLY" watermark to this. How can I achieve this? Is there a configuration item in the doxygen config file?

What do I need to do to "register" 'latexpdf' for Sphinx?

When I run Sphinx using 'latexpdf' I get an error, even though I have a complete working TeX installation on my machine:
Sphinx error: Builder name latexpdf not registered
What do I need to do to "register" latexpdf?
latexpdf is not a Sphinx builder; it is the name of a target in the Makefile created by sphinx-quickstart. This target uses the latex builder.
Executing sphinx-build -b latexpdf . _build produces the error in the question (as expected).
If you run make latexpdf, it works.
PyCharm was mentioned in a comment and the problem seems to stem from that program. The following is run when latexpdf is configured as a "Command" (Sphinx task):
sphinx_runner.py -b latexpdf <indir> <outdir>
The sphinx_runner.py script is very similar to sphinx_build (a wrapper for sphinx.cmdline.main()). Since the -b option is supposed provide the name of an actual builder, there is an error.
Use -M instead of -b. This invokes sphinx-build similarly to make latexpdf, e.g.:
sphinx-build -M latexpdf . _build
See #mzjn's answer for details.
Now have Pycharm 2016.3 generating a pdf form me based on information here: https://www.quora.com/How-to-create-a-PDF-out-of-Sphinx-documentation-tool
Install rst2pdf:
pip install rst2pdf
Edit a new Python Docs sphinx configuration and choose pdf as the command. Set input directory and directory to hold .pdf as output.
Edit the conf.py file and add the two lines that mention pdf:
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.viewcode',
'rst2pdf.pdfbuilder'
]
pdf_documents = [('index', u'documentation', My Docs', u'Me'), ]
Now run the configuration and you should get a file called documentation.pdf in the output directory.
If you are interested in a pure Python solution, the following works for me:
import sphinx.cmd.make_mode as sphinx_build
OUT_DIR = "docs" # here you have your conf.py etc
build_output = os.path.join(OUT_DIR, "_build")
# build HTML (same as `make html`)
build_html_args = ["html", OUT_DIR, build_output]
sphinx_build.run_make_mode(args=build_html_args)
# build PDF latex (same as `make latexpdf`)
build_pdf_args = ["latexpdf", OUT_DIR, build_output]
sphinx_build.run_make_mode(args=build_pdf_args)
In fact, I've made a complete Python3 script that given a few convenient arguments generates the whole package documentation as HTML and PDF from scratch, with the RTD theme. It can be pretty handy if you want it to run it on different OS or Python interpreters (in my case i wanted to run it within Blender), or adapt it to your needs. It still has some dirty spots, due to some variables being hardcoded into conf.py. Let me know if you see any issues with it!
This is how it looks like:
HTML
PDF
Cheers,
Andres

To get the current $USER in LaTeX

My friend has the following in his computer in a LaTeX document
\includegraphics[width=13.0cm]{/Users/max/Dropbox/2_user_cases.png}
I would like to have a variable for the username such that we can collaborate faster.
Pseudo-code about what I wont
\includegraphics[width=13.0cm]{/Users/`echo $USER`/Dropbox/2_user_cases.png}
How can you have such an command inside LaTeX?
I'm not sure you can access envvars from LaTeX. As Rutger Nijlunsing has said, you can try "~/" since it is an alias to "/Users/<username>".
If there are other envvars that you need to access, my suggestion is using Makefile to 'compile' the .tex (or a shell script) calling sed to replace such word.
sed -i "s/max/$USER/" file.tex
latex file.tex
bibtex ...
latex ...
in the graphicx package, you can define a folder for latex to look for all your images in, like this:
\graphicspath{{images/}}
In this particular configuration, latex looks for a folder in the same directory as your file called "images."
I don't see why you'd want to use a full path just to get image in...
Make a folder, put your .tex source file in there, create a folder for your images.
Stick you work in some sort of revision control system (git, SVN, etc etc.)
Commit often, and you're on your way.
use ~ for your homedirectory (which is probably /Users/$USER):
\includegraphics[width=13.0cm]{~/Dropbox/2_user_cases.png}

Resources