I've just started writing my PhD thesis in Bookdown and so far things are going great. The one problem I do have though is that figure captions when outputted to PDF format seem to take up only about 60% of the page width, and are centered. This is great for short captions, but most of my figure captions are in the region of 50 words long for complicated panels. Is there some LaTeX magic to make them the width of the page?
Thanks
Tom
Here is what I'm using in my .md file:
| Reagent | Amount |
| ------------------------ | -------- |
| Appropriate Buffer (10x) | 1x |
| DNA | 50-500ng |
| Restriction Enzyme | 1*U* |
| Water | - |
Table: (\#tab:restriction-generic) Schematic for restriction digestion with a single restriction enzyme.
You can make use of the LaTeX package caption:
---
output:
bookdown::pdf_document2
header-includes:
- \usepackage[width=\textwidth]{caption}
---
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
| Reagent | Amount |
| ------------------------ | -------- |
| Appropriate Buffer (10x) | 1x |
| DNA | 50-500ng |
| Restriction Enzyme | 1*U* |
| Water | - |
Table: (\#tab:restriction-generic) Schematic for restriction digestion with a single restriction enzyme. Some really long text that shows how the caption is formatted when it takes multiple lines.
Output:
Related
Using restructured text, how can I display two code blocks side by side, so that they can be compared line by line?
Here is an example of what I mean from this similar question for Markdown: How to disply two markdown code blocks side by side
Ok, so I found that the following works:
+-------------------------+-------------------------+
| | |
|.. code-block:: |.. code-block:: |
| | |
| # Code example 1 | # Code example 2 |
| | |
+-------------------------+-------------------------+
This creates a table with two columns, and puts a code block in each of them. If the two blocks have the same number of lines, they will be aligned to each other. The output looks like this:
If one wants to include an external script, it can be done like this:
+--------------------------------+--------------------------------+
| | |
|.. literalinclude:: script_1.py |.. literalinclude:: script_2.py |
| | |
+--------------------------------+--------------------------------+
Is it possible to set column widths with markdown tables in Rmarkdown? When the text in column 2 gets long the table goes to an equal split between cols 1 and 2. I reviewed answers to what seems like a similar question but nothing seems to be quite right.
I'd like something closer to Version 1 compared to Version 2.
---
title: "Untitled"
output:
bookdown::html_document2:
toc: true
toc_float: true
toc_depth: 1
code_folding: show
theme: default
highlight: tango
---
# Version 1
| Something | Else |
|:--|:--|
| Short | This is longer this is longer this is longer |
| Short | |
# Version 2
| Something | Else |
|:--|:--|
| Short | This is longer this is longer this is longer this is longer this is longer this is longer |
| Short | |
One easy way how it should work with many parsers is to use different relative widths in your table definition, such as like this:
| Something | Else |
|---------------|------------------------------------------------------------------------------------------------------|
| Short | This is longer this is longer this is longer this is longer this is longer this is longer this is longer this is longer this is longer this is longer this is longer this is longer |
| Short | |
Yihui Xie's Bookdown book https://bookdown.org/yihui/bookdown/tables.html is very clear that the cross -referencing system requires adaptations for non-kable tables. The last paragraph in this section is key, but it is (to my lay mind) inscrutable, and I would appreciate an example or two to follow.
To make matters slightly more complicated, my project uses Rchunks, which may complicate the task a bit more.
But,does anyone have examples of bookdown crossref code (perhaps including Rchunks, Rmd calls to those Rchunks or \#ref(tab:...)) that they would share, and which do not call kable?
No entirely sure what you are asking but here is an example of a manually typed table that works with bookdown:
R includes a lot of advanced mathematical functions. Table \#ref(tab:mathfunctions) shows a list of the most common functions.
Table: (\#tab:mathfunctions) Common mathematical functions in R.
| Function | Explanation | Example|
|----------|------------|-------------|
| `abs(x)` | Absolute value| `abs(-3) = 3`|
| `sqrt(x)` | Square root | `sqrt(9) = 3` |
| `log(x)` | Natural logarithm | `log(10) = 2.303` |
| `log10(x)` | Base 10 logarithm | `log10(10) = 1` |
| `log(x, base=2)` | Base 2 logarithm | `log(10, base=2) = 3.322` |
| `exp(x)` | Exponential function | `exp(1) = 2.718` |
R also allows you to yada yada yada.
I want to create an static drawing (say any animals like giraffe) using some points, lines, drawing etc. Now i want to update the drawing by passing the parameters say height of his legs, its width or its color.
The parameters are supplied from the web page. The image will be a 2D image
I am searching on which technology should i implement this for more than 10 hours but cannot find any perfect solution.
Right now i am thinking i can use Adobe flash in which i can do some programming to create an drawing and change the drawing by passing the parameters to a Flash file, i think we can pass it when we embed an flv.
Whether i am right? Or there is any other solution. I have no knowledge of any thing except asp.net
Please help.
Any help is appreciated
I'd like to build on the previous post - you could also incorporate svg graphics into the mix. This would allow you control over color, width, and height. You can manipulate SVG files with javascript (Dynamic SVG). You'll probably get that going faster than learning action script.
If you just want to be able to stretch or recolor parts of an image, you could do that using ordinary HTML parameters. Just create a giraffe image, break it into the chunks that you want to be able to resize independently, and use CSS layout or tables to assemble them. Here's an artistic rendering:
___________________________
|image 1 V__ <<|
|head |oo | <<| <--- delicious acacia leaves
| | < <<<|
---------------------------
|image 2 | | |
|neck |o| |
| | | |
---------------------------
|image 3 / | |
|body /------/ \ |
| | \ |
---------------------------
|image 4| | | | | | | | |
|legs | | | | | | | | |
| \_/ \_/ \_/ \_/ | <--- I do not know what giraffe feet look like
---------------------------
If you want to give your giraffe a short neck without changing anything else about it, you can just alter the height attribute of the second image, like so:
___________________________
|image 1 V__ <<|
|head |oo | <<|
| | < <<<|
---------------------------
|image 2 | | |
---------------------------
|image 3 / | |
|body /------/ \ |
| | \ |
---------------------------
|image 4| | | | | | | | |
|legs | | | | | | | | |
| \_/ \_/ \_/ \_/ |
---------------------------
Obviously, changing the width of just one image would cause the boundaries to no longer match up, so you'd need to change them all to the same value.
To handle color changes, you can make use of image transparency. Each image would be white, with a transparent region representing the giraffe. Then, you'd set the background color of the div or table cell to the color you want the giraffe to appear. Again, this is clunky, but it would let you do what you want without needing anything other than static GIF / PNG images and basic HTML.
From the get go: sorry if I'm not using the proper emacs terminology -- I'm relatively wet behind the ears in the emacs world.
Most of my work in emacs is for programming R, and I'm using ESS and ECB to do so quite happily. I'd like to build a custom ECB layout which uses the entire bottom of the screen as my R console, while putting some ECB-specific buffers on the left.
Using ECB-esque layout diagrams, I'd like my layout to look like pretty much exactly like "left13", except I'd like the entirety of the "compilation" buffer to be my running R console (or any shell, for that matter):
-------------------------------------------------------
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| Directories | Edit |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
-------------------------------------------------------
| |
| R Console |
| |
-------------------------------------------------------
If I can just split my buffer in two (vertically), then call ecb-activate from the top buffer (and not allow it to touch my bottom buffer), I'm imagining it could work (hence the subject of my question).
That doesn't work, though, and I don't know how to get an entier "bottom pane" out of a layout to work in the way I like using trying to use ECB's customize layout functionality.
Does anybody know if/how I can do this?
Short answer: No.
Longer answer: Unfortunately, ECB completely takes over Emacs "window" management at a very low level. So it's all or nothing. You can't comfortably combine it with regular window splitting. What you might be able to do, is to adjust the layout ECB gives you or to program a custom layout. (Some assembly required.)