Subsections in reStructuredText - restructuredtext

I'm trying to write a document in reStructuredText, but am currently facing a problem.
I want the document to have a title, this is going to be centered, then immediately after that I want a subsection.
I tried doing the following
##############
Title
##############
+++++++++
Subtitle
+++++++++
content
But when I convert this to PDF, it makes both the title and subtitle centered.

From the reStructuredText quick start guide titles and sub-titles are specified as follows (emphasis mine):
To indicate the document title in reStructuredText, use a unique adornment style at the beginning of the document. To indicate the document subtitle, use another unique adornment style immediately after the document title.
So in the reST example in the question, Subtitle is being formatted as a sub title and not a section heading since the adornment style used around Subtitle is not used anywhere else in the document. In the following, this adornment is used around two section headings, so is not unique and not treated as a subtitle:
##############
Document Title
##############
+++++++++++++++
Section 1 Title
+++++++++++++++
Section 1 content...
+++++++++++++++
Section 2 Title
+++++++++++++++
Section 2 content...
Have a play with http://www.tele3.cz/jbar/rest/rest.html This allows you to quickly try out some simple reStructuredText and test things like sub-titles vs. section titles.
Edit: Alternatively you could put some text between your title and section heading (like an abstract, for example).
P.s. I tend you use adornments above and below a heading to indicate a document title and sub-title and a single adornment below a heading to indicate a (sub-)section title. This makes it easy to see what I intended to be my title/sub-title. For example:
==============
Document title
==============
-----------------
Document subtitle
-----------------
Section
=======
Sub-section
-----------
etc.

I think it's quite natural to have a subsection start immediately under a section heading, as in
MY THINGS
My First Thing
...
My Second Thing
...
A work-around I found by trial and error is to put "\ " (backslash-space) as null content between the section heading and the subsection heading. With rst2html this has the desired effect without introducing any unwanted space.

Related

Placement of pictures in markdown/bookdown

I am writing a text in bookdown with Rstudio and want to include a picture within the text like this:
Some text goes here
```{r, fig.cap="\\label{fig:figs}figlabel"}
knitr::include_graphics("images/image.png")
```
Some other text goes here.
However, when I render the book with bookdown::render_book("index.Rmd"), The inserted picture is placed on the next page rather than where it is placed in the text. I want it to be placed between the two sentences, but it is placed below the last one.
Is there a way to control where in the text the image is rendered? I have tried to look at chunk options for images, and also in the bookdown documentation, but neither seem to document ways to control placement of figures.
LaTeX will try to find an optimal location for the figure. You can force the placement of floating figures and tables with \FloatBarrier. Note that doing so, you might end up with a lot of white space on the bottom of the page.
Some text goes here. See fig. \#ref(fig:my-fig)
```{r my-fig, fig.cap="fig caption"}
knitr::include_graphics("images/image.png")
```
\FloatBarrier
Some other text goes here.

R Markdown pdf_document - footer without header

I am adding the following lines to add a customized footer to my pdf document, found here.
header-includes:
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \fancyfoot[LE,RO]{My fancy footer}
The issue is, I get also a header, which includes first and second chapter titles. As my chapter titles sometimes are long, they overlap. I wanted to ask how to remove the header and keep the footer. If it is easier, I am interested to keep only the first titles in the header.
Adding \fancyhead{} will get you an empty header. Check the user manual for the fancyhdr LaTeX package to find out how to create custom headers and footers.
If you'd like to remove both the header and the header horizontal rule, you can add the following to your doc preamble:
\fancyhead{}
\renewcommand{\headrule}{}
You can find a similar answer at How to remove the top horizontal bar in fancyhdr.

Rmarkdown Image Skips Ahead of Text

I am putting together an Rmarkdown PDF document with the following YAML settings:
---
output:
pdf_document:
fig_caption: true
fig_crop: true
toc_depth: 3
header-includes:
- \usepackage{hyperref}
---
Within the body of the document I've inserted a few PNG images, using the following syntax
Paragraph 1..........
![Caption](path/image.png)
Paragraph 2....
And when the document is rendered, the image appears as expected within the text, between Paragraph 1 and Paragraph 2. However, I am getting some unpredictable results where the rendered image appears after Paragraph 2 in some cases and I can't manage to solve it.
I have run into the same problem. It appears if you wrap the image in "paragraph" tags, the image will be in-line with the text.
Paragraph 1...
<p>
![](image.png)
</p>
Paragraph 2...
When tackling similar issues, I've used \FloatBarrier (from the placeins package) to control positioning. I'm not the most experienced knitr rmarkdown LaTeX user, but I've had success with that before.
Basically, the images "float"; you can control what the can't float past by inserting a barrier. That description is crude, but you might find the technique effective.
\newline seems to work.
History and Overview of R
![R programming](Images/R.PNG)\newline
will insert vertical space
to keep your figure captions make sure the ![] is still in a separate paragraph (separated by blank lines above and below) in the Rmarkdown document
### Heading 1 ![This is my figure caption](`r fig_var`){width=400px}
### Heading 2
where fig_var is an r variable that contains the full path to the figure image
One option is to add
\newpage
to act in a similar way as the Floatbarrier. It is not to elegant but seems to work.
For greater clarity consider the example from above:
Paragraph 1..........
![Caption](path/image.png)
Paragraph 2....
To avoid the image to move in front of the second paragraph, you could do the following:
Paragraph 1..........
![Caption](path/image.png)
\newpage
Paragraph 2....
There is no correct answer to this.
Try adding fig.show='hold' to keep your images where they should be
The paragraphs might be skipped because Latex will try and fit the text/images with least space.
I sorted my issue out using (1) and to "work with" (2), you can use
\pagebreak in an appropriate position depending on what is before and after paragraphs 1 and 2.
This can be done only after seeing the pdf result, by better fitting of the image in question into potentially a next page (more space). Of course, it would also mean adding the page break elsewhere (e.g before or after any of the p1, p2 or the image).

Page title CSS style

Is it possible to change title font style?
I want to have my page title with font-variant: small-caps;
No we cant style it. For some information you can read W3C documentation about the title tag. It says:
The title is not part of the text of the document, but is a property
of the whole document. It may not contain anchors, paragraph marks, or
highlighting. The title may be used to identify the node in a history
list, to label the window displaying the node, etc. It is not normally
displayed in the text of a document itself. Contrast titles with
headings . The title should ideally be less than 64 characters in
length. That is, many applications will display document titles in
window titles, menus, etc where there is only limited room. Whilst
there is no limit on the length of a title (as it may be automatically
generated from other data), information providers are warned that it
may be truncated if long.

Drupal views strip HTML - Paragraphs sticking together

I'm using Drupal 6 and Views 2 to display titles and a summary of the body of some content. I wanted to strip out the HTML so that tables and images etc don't display in the node summary. It is preferable in this situation to trim the body rather than use the 'teaser'.
However, when paragraph and line break HTML is removed, the sentences get 'stuck together' - for example:
This is a paragraph. It has two sentences.
This is a second paragraph.
Becomes...
This is a paragraph. It has two sentences.This is a second paragraph.
There is no space after the second period. How can I strip out the HTML but somehow insert spaces in these situations (or achieve a similar result)?
Click on the field under 'Fields header' eg node:body body and there you will find 'strip HTML' right below trim option. Check that option and you will get desired result.

Resources