CSS class equivalent for LaTeX - css

I am trying to figure out if there is a way to apply the CSS methodology to the LaTeX template I am building. What I would like to do is to have a set of classes that apply a specific style treatment to the bracketed words. For example:
If I have three paragraphs of text, I want to have all of the paragraphs have [0.5cm] of spacing after the last line without having to add \\[0.5cm] after each paragraph.
Is there a LaTeX equivalent of defining the treatment for all paragraphs in the preamble so that it cascades throughout my document? The equivalent of:
<style> p {padding-bottom:0.5cm} </style>
I want to be able to specify multiple version of these CSS-like LaTeX classes throughout my document, so I don't need a specific solution. I need help understanding how to add custom labels/names/classes to the preamble and an example of how to use them in the document itself.
Thanks!
Ryan

It sounds like you want to define your own environment. Below is an example from LaTeX wikibook.
Put this in your preamble:
\newenvironment{king}
{\rule{1ex}{1ex}\hspace{\stretch{1}}}
{\hspace{\stretch{1}}\rule{1ex}{1ex}}
And then use the style in the document:
\begin{king}
My humble subjects \ldots
\end{king}

You could adjust the value of \parskip, see here for explanation.
\addtolength{\parskip}{\baselineskip}
Alternatively, you could just use \setlength:
\setlength{\parskip}{0.5cm}

You could create commands that change the environment (like setting parskip), and issue the commands at different points in the document. Experiment with {bracketing} to change the scope of the changes the command makes.

As far as I know, it isn't possible. :(
The tutorials here may be useful though.

Related

Different Colored Comments

Simple question about comment code aesthetics (color):
I recently noticed in someone's comment code that part of their comment color changed while using the # symbol. After experimenting with it, I noticed you also need to have an apostrophe (') right after the octothorp (#) as such:
#' #text
^--- This turned orange!
Since I'm a detailed commenter, I'd love to step things up if I could by adding color to my comments. I know part of the reason is my global IDE (RStudio) options, but I'd never seen anything change a comment's color before, so I was just curious:
Why does this occur? I've only seen # used when handling large, more-complex objects that need further specification => Ex. LargeObject#data$variable
Are there other symbols that trigger a color change? There's quotes of course (""), but quotes do not change color when they're commented out with an octothorp (#).
Also, on the image (bottom row), is there possibly a way to start and end a comment, followed by a command, all on one line? => Ex. #comment# print(summary(df))
The special highlighting you're seeing — words being highlighted after #' # — is specific to roxygen markup (a documentation-generation system for R). I don't know why that category doesn't seem to be listed/themeable (see #2).
The RStudio syntax highlighting colours are customizable (you can edit these themes visually), but based on what's documented at the link, there appears to be only one category for "comments".
This question has to do with the R parser, not the RStudio highlighting system. So the answer is "no"; everything from the first # on a line to the line break is considered a comment, no exceptions. In principle you could adjust the RStudio highlighting engine to recognize various delimiters within comments and display material following them differently, but you can't create in-line comments (as you could with /* */ in C) without modifying the R parser.

How to create exam sheets with solutions in a non-English language with R exams

In order to create the exam sheets without solution, everything works fine with exams2nops (apart from the logo which is not taken for some reason). I can add the name of the institution, change the title, and setup a non-English language and the date. But if I want to create examsheets with the solutions, then, if I understand correctly, I cannot use anymore exams2nops, but I have to use exams2pdf with template="solution" which does not take into account the institution, the date, the language, nor the title.
Any help?
You are correct that exams2nops() does not provide a version of the PDF with the {solution} environment and the complete answer text. The nops_eval() only provides a HTML report with the correct boxes that needed to be checked.
So to produce a PDF as desired you can run exams2pdf(...) or exams2pdf(..., type = "solution") after setting the same random seed that you set before running exams2nops(). If you want to modify anything like layout/logo/language/etc. in exams2pdf() you have full flexibility but need to do the work yourself. That is you need to come up with a LaTeX template file that looks the way you want. As a starting point you can take solution.tex from the package. The easiest way to get all templates shipped with the package is to run exams_skeleton() and then look at the templates folder.
Background info: exams2nops() also just calls exams2pdf() internally after setting up a suitable LaTeX template file based on the arguments specified by the user.

Xaringan: Math renders as inline code in footnote class

Using the default Xaringan CSS, if $math$ is placed in a footnote, it appears to be rendered as inline code, rather than rendering as math. I was not able to find information about this - is this just a natural limitation in Xaringan or remark.js? Or perhaps I am doing something wrong?
See basic example below:
# A Test
- This is a test<sup>1</sup>
.footnote[<sup>1</sup> This includes $\delta+\frac{2}{3}$ math.]
This will render the math between the $$ as if it were between backticks.
[UPDATE 17/12/2019] Another way to circumvent this is to replace the maths expression $\delta+\frac{2}{3}$ with \(\delta+\frac{2}{3}\) which bypasses any need for remark.js to convert $ and thus avoiding the bug there.
Yes I noticed this too. I think somehow remark.js is interfering with mathjax but I don't really know. To get around this I use the html code directly instead. So below should work:
# A Test
- This is a test<sup>1</sup>
<span class="footnote"><sup>1</sup> This includes $\delta+\frac{2}{3}$ math.</span>
[UPDATE]
The explanation of why this happens can be found here. TL;DR: remark.js removes the brackets necessary for mathjax to detect the maths.
Yihui also provided an alternate hack if the use of .footnote[] is desirable which involves adding the brackets to the inline math code:
.footnote[<sup>1</sup> This includes `\\(\delta+\frac{2}{3}\\)` math.]

Markdown syntax: problems with superscript

This is my first time using R so this is about as basic of a question as they come.
I am making a presentation using markdown (ioslides). I want to do something very simple which is to put something in superscript. According to the manual, the syntax is the following:
Lower bound = α^Full – K^ - α^Full^
The first time I tried running this, I got a pop-up screen with some options. Too quickly, I pressed enter and inadvertently chose something. Now the syntax won't run and I can't figure out what I did to undo it.
Can someone help? Thank you in advance.
Markdown allows HTML to be used if necessary, so you should be able to use the HTML sup tag.

Right align (an address) in Pandoc

Right alignment comes handy for letter addresses. Unfortunately, according to the author John MacFarlane:
The pandoc document model does not allow for alignment other than in tables, so the alignment information is simply ignored.
We can resort to raw LaTeX.
Upon trial and error (and googling) I found that this TeX syntax works as intended:
\rightline{Address 1}
\rightline{Address 2}
\rightline{etc}
Also the LaTeX equivalent does:
\begin{flushright}
Address 1\\
Address 2\\
etc
\end{flushright}
The less invasive syntax, based on the LaTeX command raggedleft, unfortunately does not work:
{\raggedleft
Address 1\\
Address 2\\
etc\\
}
This is because braces are passed verbatim (\{, \}) and not as raw LaTeX.
With reference to centre alignment, I found a user claiming that markdown supports this native (beautiful) syntax:
-> This is center align <-
but I didn't find an editor/converter supporting it.
Indeed my working examples are all against the John Gruber markdown philosophy:
A Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions.
Can you find a better way?
Particularly is it possible to simply write a Pandoc template to redefine the alignment of a header, say: ###### Right aligned?
For those that are looking for a similar question here's how to left align/right align on the same line:
**Some bolded text** **\hfill some right aligned on same line bolded text**
You'll have to imagine the result since I'm not sure how to recreate it on SO.
The best way to handle this is to put the address in a YAML metadata block (supported by pandoc 1.12+), and do the alignment in a custom template. Then your source document will be clean, without raw LaTeX, and you can modify templates to get the desired look in any output format.
Source document could look like this:
---
address:
| 23 Main St.
| Somewhere, MT 23434
...
Dear so and so,
Then in your LaTeX template you'd have something like:
\begin{flushright}
$address$
\end{flushright}
If you're writing a letter, though, it would probably be better to write a template using the LaTeX letter class.

Resources