Setting the line spacing to 1.5 pt in R Markdown - r-markdown

I am writing my thesis in r markdown and I need a line spacing of 1.5 pt for this. Is there any way to modify the line spacing in markdown? Output will be pdf.

Related

Extracting multiple lines of text between delimiters from a single cell

In Google Sheets or Excel, I would like to extract multiple lines of text between the delimiters x/ and / using a single formula.
INPUT:
x/Apple Juice/,Banana,Grape,x/Pear Juice/,Cherry,Orange,Blueberry
OUTPUT expected:
Apple Juice, Pear Juice
The input line of text may be longer or shorter and the position and instances of "x/text/" can vary.
=ARRAYFORMULA(TEXTJOIN(", ", 1, IFERROR(REGEXEXTRACT(SPLIT(A1, ","), "x/(.*)/"))))

Sublime Text: Replace with fixed width field(using regex)

Is there a way to replace an expression(a line containing multiple fields) found through regex, with fields in a fixed width format in sublime text?For instance, I have several lines of text like:
CS 210 Data Structures Laboratory (0-0-3-3)
CS 221 Digital Design (3-0-0-6)
CS 241 System Software Laboratory (0-0-3-3)
CS 203 Formal Languages and Automata Theory (3-0-0-6)
I need to replace them by something like this:
CS 210 Data Structures Laboratory (0-0-3-3)
CS 221 Digital Design (3-0-0-6)
CS 241 System Software Laboratory (0-0-3-3)
CS 203 Formal Languages and Automata Theory (3-0-0-6)
The fields in each line can be obtained separately by the regex search:
([A-Z]{2} +[\d]{3}) +((?: *\-* *\w+)+) +([\(\-\d\)]{9})
($1: course no., $2: course name, $3: credit system)In the replace expression, being able to set fixed width for each capture group will solve the problem.
find more than two consecutive spaces with regex \s{2,} and replace it with other field separators. i.e. Pipe(|)
now you have each field separated with a pipe, which is easy to managable.

Vertical spacing of cells containing a parbox

I have a complicated longtable with several levels of nested tabular environments. To get text wrapping inside cells and have the contents aligned at the top I use \parbox[t][][t], however, the height of the parbox is computed without any margin such that the following \hline overlaps with the text.
A minimal example to reproduce this behavior is
\documentclass{article}
\begin{document}
\begin{tabular} {|p{0.2\textwidth}|}
\hline
This cell looks good. \\
\hline
\parbox[t][][t]{1.0\linewidth}{
Not so happy with this.
} \\
\hline
\end{tabular}
\end{document}
This produces the following output (sorry, can't post images yet):
image of generated output
Of course, there is no reason to use a parbox in example above, but I need them in the actual document.
I would like to avoid providing the height of the parbox (such as \parbox[t][5cm][t]). Is there a clean way to add a margin either to the bottom of a parbox or before an hline?
Sorry to answer my own question, but I have found a solution by adding vspace to each cell outside the parbox.
Here's the code:
\documentclass{article}
\begin{document}
\newcommand{\pb}[1]{\parbox[t][][t]{1.0\linewidth}{#1} \vspace{-2pt}}
\begin{tabular} {|p{0.2\textwidth}|}
\hline
This cell looks good. \\
\hline
\pb{
Now I'm happy with this.
} \\
\hline
\end{tabular}
\end{document}
The output: image of generated output
I missed that before because I didn't have a space between the closing brace of the parbox and the vspace. Turns out that space is crucial.

How do I concatenate cells and add extra text?

I'm very new to Calc but a relative veteran with Excel. Unfortunately I don't have the latter available to me. I'm attempting to create a new cell inline with the data I need to use like the below
AF Afghanistan
AL Albania
DZ Algeria
with an output in Column C like this
<option value="AF">Afghanistan</option>
I've tried to use the CONCATENATE function to no avail. Could someone point me in the right direction on how to achieve this in OpenOffice Calc (Version 3).
Thanks
I suppose it's a problem of escaping the quotes, since they delimit the "extra strings", too. Anyway, it should work with CONCATENATE, using this formula:
=CONCATENATE("<option value=""";A1;""">";B1;"</option>")
EDIT:
Sorry, every time messing up argument separators (with german l11n, semicolons instead of commata are used...) With an english (US) localisation, you need this version:
=CONCATENATE("<option value=""",A1,""">",B1,"</option>")
If doubling the qoutes around the first cell reference doesn't work, try to replace it with CHAR(34) (the decimal ASCII code for double quotes is 34, while 22 would be the hex value):
=CONCATENATE("<option value=",CHAR(34),A1,CHAR(34),">",B1,"</option>")
suppose 'AF' was in column A1 and 'Afghanistan' was in column C1, then this would produce the desired result
="<option value='"&A1&"'>"&C1&"</option>"
That code would give you this output
<option value='AF'>Afghanistan</option>

Highlight columns which differer from previous lines

I have text file with numerical data written in lines; there are interspersed input lines (unknowns) and residuals lines (which are supposed to be minimized). I am investigating ways how the iterative solver handles various cases, and would like to highlight every (space-delimited) field in the residuals line which is (textually) different from the same field in the previous residuals line (2 lines above, better given by a regexp). I am free to decorate beginnings of the lines as I like, if that helps.
Is this at all possible with Vim and some regexp magic?
Example file:
input 1 2 3 4 5 6
errors .2 .2 .3 .1 0 0
input 1 2.1 2.9 4 5 6 ## here, 2.1 and 2.9 should be highlighted
errors .21 .3 .44 .3 0 0
input 1 2 3 3.9 5.2 6 ## here, 2, 3, 3.9 and 5.2 should be highlighted
errors .2 .2 .34 .9 1 0
Note: I could code script extracting differences in Python, but I want to have a look at both the actual data and the changes. When it does not work with Vim, I will process it with python and output highlighted HTML, but I will lose automatic folding capabilities.
I think that if you use arrays rather than a regex for the comparison, it might be a lot easier:
<?php
$lastRow=array()
$h=fopen('file','r');
while ($r=fgetcsv($h,0,' ')) // Retrieve a line into an array and split on spaces
{
if (count($lastRow)==0)
{
$lastRow=$r; // Store last line
}
$count++;
if ($r[0]=='input')
{
/*
* this won't find any differences the first run through
*/
$diffs=array_diff($lastRow,$r); // Anything that has changed from the last "input" line is now in $diffs
$lastRow=$r; // Only copy into $lastRow if it's an "input" line
}
/*
* Put your code to output line here with relevant CSS for highlighting
*/
}
fclose($h);
?>
I've not tested this code but I think it's shows how you could get a solution without delving into regex