R Markdown Knitting to PDF Format Question - r

This is a two-part question, both parts are probably simple:
Why do my comments appear between the code and the output? I'd rather it display as I type it. For instance:
Gives the output:
But I would prefer the "We have 7 classes of data..." line to go above the code in the PDF.
Using the second picture from above, why does the gray box containing the code in have a larger border above the code than below? I'd rather the top have the same size border as the bottom.
I'm assuming this is an easy setting to change but I can't figure it out.

Related

Hold added image position in R markdown

I want to add an image in the middle of R markdown report, but when I knit it to pdf, the image appears on the top of the page, not in the intended place. Here is what I use in R markdown:
![help_dataframe_screenshot](help_dataframe_screenshot.png)
Anyone knows how to fix it? I need the image at where I insert it, not on the page top.

rmarkdown adding blank space around headers when knitting to PDF

I am encountering a weird issue where when I knit my markdown document to a pdf, some of the headers/figures are having a bunch of line breaks/spaces buffered above and below them (see image below for both code and knit document). I cannot figure out why this is occurring. I have checked the spaces above and below the headers and nearby chunks to make sure they are consistent, as I know this can sometimes cause similar issues, to no avail. There are some headers that are seemingly unaffected, and I tried to copy/paste those over the ones that are, and yet when doing so they also get the breaks added in that space.
When removing the code chunks for my plots, however, these mysterious spacings disappear.
Any suggestions would be greatly appreciated.
EDIT:
I believe I've solved the issue, and will leave this here in case anyone has similar issues in the future. I believe the buffers are being added around the headers under which the code chunks are placed because the image would otherwise be cutoff or not fit on the page in that location. Since markdown does not want the image to be cut off, it adds a space buffer to make sure it will fit on the page. You can work around this by either changing the size of the image or the location to make sure that it will fully fit on one page without being cut off.

R Bookdown: code wrapping does not work for HTML gitbook output

I have code-blocks that I want wrapped in a R bookdown format. I am rendering to gitbook. All the code-blocks currently don't wrap, instead they give a horizontal scroll bar.
When I take the same code-block, and render it in a regular RMarkdown file to html, code-wrapping works instantly.
I know that when you want to force a certain character-width, you can so using the answers provided here. But this doesn't work either.
Is this a limitation of the gitbook format? Is there any way to work around it?

Warping text using CSS

In CSS or SVG, is it possible to warp text so it looks like it is written on a sphere or looked at using a magnifier?
Something similar to this
I have been look over the internet but could not find any guides.
All of the comments telling that it can't be done are wrong. YES IT CAN BE DONE. Well, it's not easy but possible. Let's start from the beginning.
1. Don't even think about writing the code. You need a vector graphics software. I used Corel Draw to this project.
2. You need to create all text, apply all transformation, style each letter, add shadow, background or whatever you need.
This is a simple project I created. It's a fast draft, but you can style the text exactly as on your photo. You can easily make all letters in the middle bigger than the others.
(sorry it's not in English!)
3. Force Corel Draw or any other program to save svg with fonts not curves.
4. I analyzed the code and I see that each letter is saved separetly as a glyph:
<glyph horiz-adv-x="222" unicode="l"><path d="m63.876 0.23623l-2.504 715.49 87.971 0.33072 2.504-715.49-87.971-0.33072z"/></glyph>
Some other letters are saved as text and transformations are applied:
<text class="fil1 fnt0" x="1045" y="1269"><tspan rotate="335">L</tspan></text>
5. FULL CODE looks like this. It's long. I minified it a little bit.
FIDDLE: https://jsfiddle.net/ubw1rdq7/
SOLUTION 2 - MUCH EASIER
It's not fun if you have each letter saved separetly because the file may be huge. You can save your text as a curve and have only one path. This will behave like an image but you can inline the code into your html.
Here is a fiddle:
https://jsfiddle.net/wyfhfjo4/
In both cases all code is over 30kb in size and I made only simple transformations. i hope I gave you some idea how you can achieve desired effect. 99% of the project is to work in vector editing software like Corel Draw and apply all transformation to the text.
For any 3d transformation it's better to transform the text to curves as it will definitely be easier. As an output you will get a path not glyphs.
It is possible to do this using an feDisplacementMap in SVG, but this is currently bugged in current Chrome, so not very useful to you.

BIRT Report - Multiline text underlined to the full width

I'm trying to create a report with a layout as shown in the picture. The value of each field is underlined to the full width of the report. If it occupies more than one line each line is underlined. And there is also a short comment under the first line explaining the meaning of the field (shown in parentheses).
When we faced the same problem using JasperReports we had to create a custom component for that purpose. Does anyone know what the solution in BIRT might look like?
The only way I can think of is to calculate the line wrapping yourself, eg. converting your long text into a series of single lines.
Say you find a way to do this in a scripted data set, using the long text as an input.
You could then use a table item to render these single lines in the layout; using the bottom border to create the underlines (or possible an empty extra detail row with a top border and a height of 2pt to create nice line spacing).
Now how would this scripted data set look like?
I think when you study the source code of BIRT, you'll probably somewhere find a utility function that calculates the width (in whatever units) of a given text in a given font and size. Maybe this is also somewhere inside java.awt or inside iText (com.lowagie.text).
Then it is possible to call this function from inside Java Script and - with more or less logic - to use this as a basis for your scripted data set. But I think this will take a few hours to code.
If you manage to do this, it'd be nice if you post the solution here.

Resources