reStructuredText Multilevel - restructuredtext

How can I get such a structur with reStructuredText? Is it even possible?
1. Title
1.1 Subtitle
1.1.2 SubSubtitle
1.1.2.1 SubSubtitle
1.2 2ndSubtitle
1.2.1 2ndSubSubtitle

Did you look at the Sphinx documentation for nested lists? Your question should show that you made some effort, including what documentation you read, what you tried, what you expected, and what you observed.
Nested lists are possible, but be aware that they must be separated from the parent list items by blank lines:
* this is
* a list
* with a nested list
* and some subitems
* and here the parent list continues
Substitute #. for *.

So I found the answer here:
Title
=====
Subtitle
--------
___________
SubSubtitle
___________
SubSubSubtitle 1
________________
SubSubSubtitle 2
________________
_____________
SubSubtitle 2
_____________
Title 2
=======
The Output would be (if numbered doctree):
1. Title
1.1 Subtitle
1.1.1 SubSubtitle
1.1.1.1 SubSubSubtitle 1
1.1.1.2 SubSubSubtitle 2
1.1.2 SubSubtitle 2
2. Title 2
For more information check out: http://docutils.sourceforge.net/docs/user/rst/quickstart.html#sections

Related

what is the '0' meaning in rpm conditional macros

When reading some rpmbuild spec files, I come across some of the conditional macros which puzzle me.
example1
%if 0%{?rhel} > 7
blah blah
%endif
# I understand the above block tries to check if the
# red hat enterprise linux version is above 7, then blah blah
# But what is the usage of the '0'?
example 2
%if 0%{!?pkg_name:1}
%define pkg_name foo
%endif
# I understand the above block tries to check if the pkg_name
# is not defined, then define it with the value foo.
# But what is the usage of the '0'?
My guess is that '0' indicates the next expression to be either 'nil' or a number so that rpm would consider them as a number (such as 06, 0, or 01 in above examples) instead of a string or empty string. But I am not sure about it.
Unfortunatly, most of the online tutorial materials did not cover this topic.
You got it right; it's a safeguard. The %{?rhel} says "replace with the rhel macro if it exists and it is OK if it does not (the ?)."
So, if rpmbuild replaced it with nothing, the resulting if > 7 would barf.

R/exams: prevent page breaks between two paragraphs in exams2nops

I am currently working with the R/exams package, specifically creating exams using the exams2nops function and the order of the questions is randomized. Everything works fine except for one detail: The samepage = TRUE option only prevents page breaks within a paragraph. For my purpose it is however necessary not to split any of the exercises. Within one text it would still be possible to write only one paragraph (although this is not helpful for clarity). Unfortunately, whenever I need to include a table, I am forced to start a new paragraph which is not "protected" against page break. Due to the randomization there are always some copies where text and tables are splitted to multiple pages. I tried .Rmd as well as .Rnw files and also tried to integrate some LaTeX functions such as \nopagebreak and \needspace without success. So far, I am not too experienced with LaTeX and also with Google's help I did not find a solution.
Here is a minimal example of what kind of exercises I am talking about:
.Rmd
Question
========
Some kind of question:
| A | B | C |
|:-:|:-:|:-:|
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
| 1 | 2 | 3 |
Answerlist
----------
* First option
* Second option
* Third option
Some further informational text.
.Rnw
\begin{question}
Some kind of question:
\begin{center}
\begin{tabular}{ccccccr}
$\text{A}$ & $\text{B}$ & $\text{C}$ \\
$\text{1}$ & $\text{2}$ & $\text{3}$ \\
$\text{1}$ & $\text{2}$ & $\text{3}$ \\
$\text{1}$ & $\text{2}$ & $\text{3}$ \\
$\text{1}$ & $\text{2}$ & $\text{3}$ \\
$\text{1}$ & $\text{2}$ & $\text{3}$ \\
\end{tabular}
\end{center}
Some further informational text.
\begin{answerlist}
\item First option
\item Second option
\item Third option
\end{answerlist}
\end{question}
I am not sure what to try.
The samepage = TRUE option only enforces that the {answerlist} is in a {samepage} environment - but not the entire {question}.
The easiest option to accomplish what you want to do seems to be to re-define the {question} environment in the header = argument. You could either try to put everything into a {samepage} environment via
exams2nops(...,
header = "\\renewenvironment{question}{\\item \\begin{samepage}}{\\end{samepage}}")
This may have to be coupled, though, with some \nopagebreak commands in between paragraphs. (See: Make an unbreakable block in TeX)
A simpler solution might be to put every exercise on its own page by including a page break at the end of each exercise:
exams2nops(...,
header = "\\renewenvironment{question}{\\item}{\\newpage}")
In case you are not familiar with the LaTeX syntax above:
\renewenvironment{foo}{...}{...} re-defines the environment "foo".
The first ... is what is executed at the beginning of the environment.
The second ... is executed at the end.
By default, only \item is executed at the beginning to increase the enumerated counter for the exercises.
The double backslashes (e.g., \\item) are required in R to escape the backslashes as they are a special character.

How to design three dimension nosql database using Firebase

I am using Firebase as database for an e-commerce app.
I got a problem in the product catalog design.
My idea is:
1. One product can have different sizes. (e.g. S, M, L, XL)
2. One product can also have different colors. (e.g. black, blue, bronze, red)
3. The price can vary depends on different size OR different color, e.g. a medium size T-shirt in black is $100, while the same size T-shirt but in blue is $150.
In other words, there can be up to 9 different prices for one T-shirt which has 3 sizes and 3 colors.
Below is the design I can come up with.
I stored the sizes, colors, and the prices in the child 'sku'.
Under this child, I put the price for different color in the child 'price'
But I think it is not the best design so hope anyone could advise a better solution.
For security reason, I have hidden part of the unique key.
You should remodel your database according to your needs.
Products
|
-Kj53453453453453 //ProductId
| |
--- Small_Size: true
| |
--- Black_Color: true
| |
--- Quantity: 7
| |
--- Price: 100
| |
--- ProductId: T_SHORT_ID // which must be the same for all t-shirts of same type
|
-Kj53453794677886 //ProductId
|
--- XL_Size: true
|
--- Red_Color: true
|
--- Quantity: 9
|
--- Price: 65
|
--- ProductId: T_SHORT_ID // which must be the same for all t-shirts of same type
Sizes
|
--- Small_Size: "S"
|
--- Medium_Size: "M"
|
--- Large_Size: "L"
|
--- XL_Size: "XL"
|
--- XXL_Size: "XXL"
Colors
|
--- Black_Color: "Black"
|
--- Blue_Color: "Blue"
|
--- Bronze_Color: "Bronze"
|
--- Red_Color: "Red"
Using this model you'll be able to have a node for each product separately. This means, let say for the first product which has the -Kj53453453453453 as an id, you know that is back and the size si S. For this type of product you know also that you have 7 pieces. When someone is buying a piece, the only thing you need to do, is to decrease the quantity by one, that's it!
Creating the correct queries, you'll be able to display everything from your database, all products, all sizes, all colors, all products that are black, all products that have the size of XL and so on.
Hope iti helps.

EBNF rule into BNF

Hi I am having a lot of trouble with this problem and I came across a lot of sites but found this post How to convert BNF to EBNF to be very helpful but I just don't know where to start with this example.
<decimal_literal> --> (0|1|2|3|4|5|6|8|9){0|1|2|3|4|5|6|7|8|9|_}
In this rule the parenthesis and curly braces are metasymbols. It needs more than 1 rule and may need to introduce 1 or more new non-terminals.
This is the textbook I am using http://umsl.edu/~mfrp9/misc/cpl.pdf page 131 shows an example but I can't apply it to this problem. If someone can please explain the solution to this problem step by step so I can learn it to do similar problems is greatly appreciated.
This looks plausible as a translation to the BNF from p131 of the book.
<decimal_literal> ⟶ <decimal_digit>
| <decimal_literal> <decimal_digit_or_underscore>
<decimal_digit> ⟶ 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
<decimal_digit_or_underscore> ⟶ <decimal_digit> | _

Unix diff to only print relevant diff

I have these two files
File: 11
11
456123
File: 22
11
789
Output of diff 11 22
2c2
< 456123
---
> 789
Output to be
< 456123
> 789
I want it to not print the 2c2 and --- lines. I looked at the man page but could not locate any help. Any ideas? The file has more than 1000 lines.
What about diff 11 22 | grep "^[<|>]"?
Update: As knitti pointed out the correct pattern is ^[<>]
Diff has a whole host of useful options like --old-group-format that are described very briefly in help. They are expanded in http://www.network-theory.co.uk/docs/diff/Line_Group_Formats.html
The following is producing something similar to what you want.
diff 11.txt 22.txt --unchanged-group-format="" --changed-group-format="<%<>%>"
<456123
>789
You might also need to play with --old-group-format=format (groups hunks containing only lines from the first file) --new-group-format=format --old-line-format=format (formats lines just from the first file) and --new-line-format=format etc
Disclaimer - I have not used this for real before, in fact I have only just understood them. If you have further questions I am happy to look at it later.
Edited to change order of lines

Resources