Make sphinx build latex PDF in nonstopmode - latex

i am using sphinx to build my latex document but everytime i run the make latexpdf command, latex stops the build and asks for user input -- latex is not running with nonstopmode. In the past i was able to put the nonstopmode in a makefile and use "-use-make" with latexmk to compile everything. Did some digging on Sphinx and can't really find what i am looking for.

The -interaction=nonstopmode option can be provided via the LATEXMKOPTS Makefile variable:
make latexpdf LATEXMKOPTS="-interaction=nonstopmode"
See https://www.sphinx-doc.org/en/master/usage/builders/index.html#sphinx.builders.latex.LaTeXBuilder.

Related

Creating pdf from subdir using latexmk -pdf

-Main Directory
- sub direcory
-xx.tex
- sub directory
-yy.tex
I am trying to create pdf file for all latex files, but it only works if I am in sub directory folder
example C:Users/Desktop/MainDirectory>sub directory latexmk -pdf I will get xx.pdf file
However if I did C:Users/Desktop/MainDirectory> latexmk -pdf
I will get error, saying No file name specified, and I couldn't find any
latexmk -pdf will look for a .tex file in your current directory. If it doesn't find any in the current directory, it doesn't recursively search for them anywhere else. After all, how does it know whether it should compile xx.tex or yy.tex, or how deep it should go?
You can provide a filename to it, though, telling it what file to compile, as latexmk -pdf subdir1/xx.tex, and it will output the files in the current working directory.
Note: this is probably not the best practice, you might as well go into subdir1 and run the same command (latexmk -pdf xx.tex) with the output-directory=.. command. I don't know why you would want all your tex compiles in the same folder, though, and separate the source codes.
On another note, while I see you're using Windows, you could recursively run all your texfiles in subdirs with the find command in Linux, as this: find . -name *.tex -exec latexmk -pdf {} \;. This might lead to issues if some texfiles have the same name. Omit the trailing -exec... to run a dry-run to see which files you want.

Sublime Text 3 LaTeXTools plugin won't compile on Debian

When doing Ctrl+B on SublimeText3, the following error is output:
[Compiling first.tex]
TraditionalBuilder: Invoking latexmk...
COULD NOT COMPILE!
Attempted command:latexmk -cd -e $pdflatex='pdflatex -interaction=nonstopmode -synctex=1 %S %O' -f -pdf first.tex
Build engine: Traditional Builder
Running the exact same command compiles a pdf file just fine.
This answer does not solve the problem, as I've
Removed spaces around "="
Done a "Reconfigure LaTeXTools and migrate settings".
Made sure pdflatex is installed.
Made sure the path for texpath is correct.
If your command runs on terminal then most likely there is an issue either with the path or with the command itself (in the file). There has been some update to the README file by the developer:
some distros do not want a space before and after the = in $pdflatex = %E. But some do want the space there (sigh!)
sometimes latexmk is not on the PATH, or the path is not correctly picked up by ST. In this case, instead of "latexmk", use "/usr/bin/latexmk" or wherever latexmk is in your system.
some distros require quoting the $pdflatex assignment, as in "$pdflatex = \"'%E -interaction=nonstopmode -synctex=1 %S %O'\""
So it might take a while but you'll find it eventually in the settings or the traditionalbuilder.py file.
Also when I tried putting /usr/bin/latexmk, latex did not produce the correct pdf (I checked it with few changes and it just opened the old pdf) but in your case it might work.
Also, at least in Arch Linux I can't run sublime with sublime-text but instead with subl so I changed that too in the settings (I don't know if it actually matters) and I needed to change the permissions for the files because user-run sublime could not access my settings files!

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

Erlang - Makefiles

Hope everyone is doing well
I am having a problem with make files in erlang on windows. I can't seem to get the following code to work.
.SUFFIXES: .erl .beam
.erl.beam:
erlc -W $<
ERL = erl -boot start_clean
MODS = main send get loops
all: compile
${ERL} -pa 'G:\Documents and Settings\Administrador' -s main start
compile: ${MODS:%=%.beam}
clean:
rm -rf *.beam erl_crash.dump
The files I am trying to compile are main.erl send.erl get.erl loops.erl
I save the make file as an .exe
And the type
make [main]
into the windows shell
All it gives me is a wierd popup error. Is the make [main] command correct?
And is my actual code right?
Thanks for the help,
-B
Several errors here:
The indented "ERL=" line won't work right. Leading tabs are special to make. You do not have complete formatting freedom, as with some other languages.
The make file should be saved as Makefile, no extensions. Case may or may not matter to your particular "make" program. All versions of make accept Makefile, however.
The brackets on your command line will never work. I assume you're cut-and-pasting them from somewhere, but they were probably using "[main]" as an example text you're supposed to replace, including the brackets.
"make main" will also fail because you don't have a "main" target in this Makefile. "make all", "make clean" and "make compile" will work, as will several implicit targets, like "make loops.beam".
You really should get a book on make, if you're going to continue to use it. I like O'Reilly's Managing Projects with GNU Make, 3/e by Mecklenburg, available for free online or in dead tree form. The GNU make manual is also available online and as dead trees.
You probably shouldn't be using traditional "make" here, however. For purely Erlang projects, Emakefiles are shorter, clearer, and just overall better. They're not so great for building other things along side your Erlang project, but you can always do both: the Makefile uses "erl -make" to kick off the Erlang build, and does everything else itself.
Your actual code looks more or less correct. You should remove the indentation for the line starting with ERL, and make sure that all the indented lines have TAB (not SPACE) in the beginning. (Unless you have a localised version of Windows, you should check the spelling of Administrator as well.)
The name of your Makefile should be Makefile (with no file type ending at all), and you should run it with make. Just writing make in the command line will run the topmost make-command (which in your case is 'all'). If you want to run any of the other commands (or all explicitly), then just add that to your make command, like "make clean", "make foo.beam".
Also consider putting your source files in src/ and your compiled files in ebin/ since that is the Erlang standard.
I recommend this page for further information about make (if you are using GNU Make): http://www.gnu.org/software/make/manual/make.html

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