-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Theorem/Lemma/Definition Custom Blocks #152
Comments
I did think about this when I started this project, but I didn't come up with a simple solution. I'm preparing the CRAN release of bookdown right now, and I'll reconsider this feature in the next version. Basically there are two possible ways on my mind: 1) As you described, use custom blocks (the major drawback is that it is not easy to use all Markdown features in these blocks at the moment; #117); 2) Hack the definition list or example list http://pandoc.org/README.html#definition-lists using some sort of special tokens and restore them to thereoms/lemmas/whatever. |
All these environments have been implemented. Please see the documentation at https://bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html |
Praise be @yihui . |
Environment theorem not working for me. When I compile pdf I get:
and theorem show just the typed text with different font but not at all as in the documentation |
After a bit of configuration, the theorem environments do work. Questions:
|
Thank you @coatless very much. |
2 and 3 are not necessary. Theorems work for HTML/EPUB output as well. You can also leave the preamble empty, and bookdown will define the environments for you. The documentation said:
|
I agree that 2 is unnecessary. This was primarily to make sure that the document was not being knitted (if open in a non-bookdown rstudio project). This is a known issue that a few of my collaborators have run into. On 3, I disagree. I'm not sure that Without defining the
I came to this realization after observing the example text, which explicitly loads bookdown/inst/examples/latex/preamble.tex Lines 92 to 98 in 1254a81
|
@coatless I'm loading amsthm explicitly only because I wanted to increase the vertical space above the theorems in the bookdown book, which uses the LaTeX class from Chapman & Hall and the spacing above theorems was too tight. This is only for cosmetic purposes. If your book cannot compile without defining the theorem environments, it is either a bookdown bug or there was something wrong in your book, and I'll need a reproducible example. I didn't define the theorem environments in the bookdown book, and it generates the PDF without any problems. |
Is there any way to get a list of definitions / theorems etc at the end of the book? |
@stevepowell99 Possible, but not very straightforward. Theorems are not different with normal R code chunks, so chunk references will still work: http://yihui.name/knitr/demo/reference/ Basically |
sorry, I just meant to place an index of definitions at the end, but to leave the actual definitions where they belong, in the text. |
@stevepowell99 If you mean a LaTeX index, please see the section |
V sorry if I wasn't clear. The short version is this: presumably bookdown, by the end of the book, knows all the definition labels which have been created in the text? So one could just loop / lapply through them and print them all out, aka Index of Definitions. So the user can look to see, aha, where is "bar2" defined, here it is in the Index of Definitions, let's click on it to get to the definition of bar2 in the text. Long version:
...
and then, presumably at the end, I can already do this... ##Index of definitions ... but I have to know all the labels I created in the text and I have to type them. If bookdown knows about all the definition labels I have created, it could make such an index automatically. |
@stevepowell99 By the end of the book, you can obtain all labels of definitions via |
@stevepowell99 FYI: finally found some time to type an answer on SO http://stackoverflow.com/q/40735727/559676 |
Is there any way to change the names |
thanks - now I can't see how to translate the token |
@stevepowell99 No. For HTML output, you only get part numbers like I, II, III, IV, ... For LaTeX output, you have to figure it out by yourself how to change the PART name (may be something like |
For LateX output you have to put the code below before the chapter which begins your part: (PART) Name of part {-}For example if you have book organized: Part 1 Chapter 1 Chapter 2 ... Part 2 Chapter 1 Chapter 2 ... So you begin Chapter 1 in Part 1 with (PART) Name of part 1 {-}and Chapter 1 in Part 2 with (PART) Name of part 2 {-}Like this you get the organization you want |
Thanks @endri81 - I don't have chapter numbering so had left off the {-}, and that led to me seeing PART actually printed before the header, which I didn't want, which is why I wanted the translation ... In short: when writing |
In latex
In bookdown, it prints at
Is it possible the temporarily change the printed name of the proof environment? |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
I'm trying to provide a way to use theorems/lemmas/definitions.
The main way I see about going about this is via the custom block declaration:
To enable this feature I'm running into a roadblock of not being able to:
For 1. it seems as if
caption = "Fermat's Last Theorem"
could be passed through to the block more options would be possible.For 2., I'm pretty sure this isn't possible due to the restriction on the
\ref
tag.The text was updated successfully, but these errors were encountered: