sphinx add a page break in my pdf with latexpdf? - pdf

I generate a documentation from rst to pdf with latexpdf and sphinx.
How can I add some page break (=new page) in my PDF?
For now I use PageBreak but it only work with rst2pdf.
.. raw:: pdf
PageBreak

You can use raw latex.
.. raw:: latex
\newpage

Maybe a slightly better solution, which also "flushes" all pending floats:
.. raw:: latex
\clearpage

Related

LaTeX introduces non-existent excess space on pdf insertion

I try to insert a PDF file into my LaTeX document. It is properly cropped (by using the "Inkscape trick") and should easily be inserted without a problem.
LaTeX however, introduces a huge white space in the document which forces itself to create a "blank" extra page just to fit the PDF to the pages.
Just like this:
This is the code creating the problem.
\end{minipage}
... % Other code
\pagebreak
\subsection[Diagramm]{\uline{Diagramm}}
\vspace{-15pt}
\begin{figure}[H]
\centering
\includegraphics[height=0.98\textheight]{Abbildungen/ASMD_Diagramm_v2_X.pdf}
\caption{ASMD-Diagramm}
\label{Fig ASMD-Diagramm}
\end{figure}
... % Other code
\pagebreak
Now I have another PDF which is inserted properly and exactly as expected.
I have tried the following already:
Recrop the PDF
Using the trim command of \includegraphics
Resizing
Using other file formats (all were not satisfactory)
To be honest I don't know much about LaTeX and am more of a beginner-intermediate user than someone who really know this stuff. But this bothers me and has bothered me for quite a long time already. Anyone has any idea on how to fix this or what I am doing wrong?
Thank you!
Solved the problem. As discussed with samcarter, the space around the pdf file in the document seems to have been too small, so LaTeX couldn't accomodate for the caption, header, etc.
By trial and error, I just changed the size from:
...
\includegraphics[height=0.98\textheight]{Abbildungen/ASMD_Diagramm_v2_X.pdf}
...
to
...
\includegraphics[height=0.95\textheight]{Abbildungen/ASMD_Diagramm_v2_X.pdf}
...
and now it fits quite well on the page.

Struggling with PDF output of bookdown

I thought it would be a good idea to write a longer report/protocol using bookdown since it's more comfortable to have one file per topic to write in instead of just one RMarkdown document with everything. Now I'm faced with the problem of sharing this document - the HTML looks best (except for wide tables being cut off) but is difficult to send via e-mail to a supervisor for example. I also can't expect anyone to be able to open the ePub format on their computer, so PDF would be the easiest choice. Now my problems:
My chapter headings are pretty long, which doesn't matter in HTML but they don't fit the page headers in the PDF document. In LaTeX I could define a short title for that, can I do that in bookdown as well?
I include figure files using knitr::include_graphics() inside of code chunks, so I generate the caption via the chunk options. For some figures, I can't avoid having an underscore in the caption, but that does not work out in LaTeX. Is there a way to escape the underscore that actually works (preferrably for HTML and PDF at the same time)? My LaTeX output looks like this after rendering:
\textbackslash{}begin\{figure\}
\includegraphics[width=0.6\linewidth,height=0.6\textheight]{figures/0165_HMMER} \textbackslash{}caption\{Output of HMMER for PA\_0165\}\label{fig:0165}
\textbackslash{}end\{figure\}
Edit
MWE showing that the problem is an underscore in combination with out.height (or width) in percent:
---
title: "MWE FigCap"
author: "LilithElina"
date: "19 Februar 2020"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r cars}
summary(cars)
```
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE, fig.cap="This is a nice figure caption", out.height='40%'}
plot(pressure)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
```{r pressure2, echo=FALSE, fig.cap="This is a not nice figure_caption", out.height='40%'}
plot(pressure)
```
Concerning shorter headings: pandoc, which is used for the markdown to LaTeX conversion, does not offer a "shorter heading". You can do that yourself, though:
# Really long chaper heading
\markboth{\thechapter~short heading}{}
[...]
## Really long section heading
\markright{\thesection~short heading}
This assumes a document class with chapters and sections.
Concerning the underscore in the figure caption: For me it works for both PDF and HTML to escape the underscore:
```{r pressure2, echo=FALSE, fig.cap="This is a not nice figure\\_caption", out.height='40%'}
plot(pressure)
```

Knitr Spin and Rmarkdown Fig.cap (figure caption). Producing double numbering pdf document

I am referring to this Suppress automatic figure numbering in pdf output with r markdown/knitr
which I don't think was answered fully.
Essentially, I am using knitr::spin and rmarkdown to produce word, pdf and html documents.
For word, there appears to be no numbering when one puts in
+fig.1, fig.cap = "Figure name"
You only get an output Figure name in the caption.
To solve that, I used captioner class.
figs = captioner("Figure")
That works fine for word
But I am not faced with rewriting the script for pdf document as the caption turns up as figure 1: figure 1: The name
I am using knitr::spin to actually generate the RMD document for forward outputs in word and pdf.
I am not sure I can use hooks in knitr::spin, as I have tried it as advertised but can't get it to work.
I also tried
header-includes: \usepackage{caption} \usepackage{float}
\captionsetup[table]{labelformat=empty}
\captionsetup[figure]{labelformat=empty}
as suggested somehere to surpress the prefix for pdf but I get errors from pandoc. It uses pdf2latex.
I am not sure how one would query the output format in knitr::spin to actually produce different actions for different formats which could be a solution although cumbersome.
Thank you so much for your help from a novice.

Is this Adobe Postscript?

I am doing a massive set of file conversions and several of them happen to be ".dat" files. When I open them I see that the first line is "%!PS-Adobe". Here's an example.....
%!PS-Adobe
^M%c$in
^M/c$in {72.0 mul} def
^M%DEFINE MARGINS
^M/C$LMAR .2 c$in def %LEFT MARGIN
^M/C$RMAR 8.4 c$in def %RIGHT MARGIN
^M/C$TMAR 10.8 c$in def %TOP MARGIN
^M/C$BMAR .2 c$in def %BOTTOM MARGIN
^M/C$CF /Courier def %saves /Courier as C$CF
etc...
Am I correct in assuming that these are indeed Adobe Postscript files and ** NOT ** PDFs?
How hard is it to convert these to PDF? I was thinking command line perl via ImageMagick or something but right now I'm a little stumped about what's been handed to me.
Thank you SO Much...
Janie
You can convert these to PDF using Ghostscript and the pdfwrite device, or for simplicity the ps2pdf script supplied with Ghostscript.
Yup, that's Postscript. A PDF would start with "%PDF". If the text "^M" is literally there like that, then it was created on a Mac and got screwed up being copied to or edited on other platforms. (Maybe it was when the sample was pasted into the S.O. edit box?) It defines some variables with dollar signs in their names, which makes it look funny.
%!PS-Adobe is the signature for conforming Postscript files. (Non-conforming Postscript can get by with %!.) The signature for PDF files is %PDF-.

Putting citation text on same slide with LaTeX Beamer

By default, using \cite in the Beamer class of LaTeX places the actual citation information at the end of the presentation on a separate slide containing the bibliography. How does one get the citation information, instead, on the same slide as the citation (the expected, courteous practice for most presentations)?
If you use the biblatex package, you can insert a complete bibliographic entry with the \fullcite command.
To have the citation at the bottom of the same slide, we can use \footfullcite instead of \fullcite.
Complete steps would be:
Include \usepackage{biblatex} and
\bibliography{<your_bib_file>} in your preamble.
Use \footfullcite{paper} in your frame.
I have used the bibentry style for this (part of natbib), which just allows you to write \bibentry{key} which directly expands to the full bibliographic entry.
So here is a minimal (but complete) working example: Assuming .bib file is named as biblio.bib:
\documentclass{beamer}
\usepackage[style=verbose]{biblatex}
\bibliography{biblio}
\begin{document}
\begin{frame}
Some text.\footnote{Some text in a footnote.} Some more text.\footcite{foo12}
\end{frame}
\end{document}