I am writing a document that has a number of figures, some of them are ASCII art and some are regular PNG images.
When I put a caption before the the image it recognizes it as a figure and displays it "Figure X Caption text" under it. But, when I put the same caption before ASCII art image it recognizes it as a caption, but doesn't put any "Figure X" in front of it.
Is there a way to number all of them consistently as figures?
An example of the adoc source would be useful. I am not sure if you have your ASCII art image in a block or not. I will assume that you have it in a block.
You can control the caption test by using :figure-caption: and :example-caption:. You could set the caption text to be the same, but unfortunately this will create a numbering duplication, since they are tracked seperately.
I would recommend adding a block around your image. So for example if you had:
.Image Caption
image::312.jpg[alt]
.Text Caption
====
Hello world
====
Which would render as:
You could use:
.Image Caption
====
image::312.jpg[alt]
====
.Text Caption
====
Hello world
====
Which would render as:
An alternative would be to unset :figure-caption: and :example-caption:, and add the number via a counter on your caption. For example:
:example-caption!:
:figure-caption!:
.Figure {counter:figure-number} Image Caption
image::312.jpg[alt,width=50]
.Figure {counter:figure-number} Text Caption
====
Hello world
====
Related
While making VSCode Extension I have a requirement to show decorations on a file. Then while you hover over that decoration you can see the default hover with some information you want to show. I am using the following code to create the hover using MarkDownString for VSCode. Even after using "float:right;" in the span the view comment section won't move to the extreme right of the hover. It would just stay in the left. Can someone help me with the way to make it right aligned? Screenshot added below for reference.
const myContent = new MarkdownString(`<span style='float:right;'><a href='#'>View Comment</a></span>`);
myContent.isTrusted = true;
myContent.supportHtml = true;
const decoration = { range, hoverMessage:myContent };
Screenshot
I want the highlighted red box area to be in extreme right of the hover. [The image used is just for reference].
After trying the same thing, I found this question still unanswered.
The MarkdownString documentation states that:
When supportHtml is true, the markdown render will also allow a safe subset of html tags and attributes to be rendered. See https://github.com/microsoft/vscode/blob/6d2920473c6f13759c978dd89104c4270a83422d/src/vs/base/browser/markdownRenderer.ts#L296 for a list of all supported tags and attributes.
Looking at the code linked, we can see that while "span" is allowed the "style" and "class" attributes, they are very strictly filtered and only allow some of the vscode built-ins to be used.
So, while styling elements with inline CSS or even a custom class might be possible, there is another approach to this - using Markdown tables, which get translated into HTML tables and allow custom alignment.
For example, what I ended up using was something like:
new MarkdownString(`
| |
| ---: |
| the very long line we want the below link to right-align to |
| [Link text](https://linktarget "Link hover message") |
`)
The idea came from the github issue linked in the the source file mentioned above.
A couple of notes:
codicons are still supported inside Markdown tables;
the HTML table generated does not expand to 100% of the hover message box, so if you want to right-align the link text with a longer line, they have to be in the same Markdown table;
Markdown table detection is very picky about spaces and newlines, you might have to play a bit with the formatting of your string for vscode to correctly transform it into a HTML table;
the Markdown table header cannot be omitted, at least that was the conclusion of my testing; it can however be empty;
the resulting HTML table might add some small invisible borders, I haven't investigated, but my alignment with other rows in the hover seemed 1px off;
trying to bypass the Markdown table creation and writing my own HTML table broke codicons support, although I haven't investigated that too much either;
This is for Papaja. How do I get rid of figure captions at the bottom of the figure. My figure caption is quite long and I am going to a figure list. Now, I get both, and the figure caption runs out on the bottom of the page. Thanks, Jeff
There are currently two options to accomodate long figure captions or tall figures. You can adjust the line spacing/font size or, as you are doing, use a separate list of figure captions. I'll briefly explain both approaches.
1. List of figure captions
a) The LaTeX way
You can suppress the captions (defined by the chunk option fig.cap) below all figures by adding the following to the YAML front matter:
figurelist: yes
header-includes:
- \captionsetup[figure]{textformat=empty}
b) The knitr way
If you would rather suppress figure captions only where necessary you can instead get knitr to do this.
Set the figure short caption via the chunk option fig.scap. To ensure that fig.scap takes effect, knitr requires that the chunk specifies out.width, out.height, or fig.align, as explained here. Remove the figure caption below the figure by setting fig.cap = " ".
Finally, I generally recommend to specify figure (and table) captions, especially long ones, using text references (e.g., (ref:reference-label). Taking all of this together, the following should do the trick:
(ref:figure-caption) This is a long figure caption!
```{r fig.cap = " ", fig.scap = "(ref:figure-caption)", out.width = "\\textwidth", fig.height = 7}
plot(cars)
```
Make sure that you include figurelist: yes in the YAML front matter and that you are using at least the development version of papaja with the commit hash d6227d8a750c6e67a323828a7cb0b8b8331aeac7, e.g. devtools::install_github("crsh/papaja#d6227d8a750c6e67a323828a7cb0b8b8331aeac7").
2. Adjust line spacing and font size
As mentioned in the manual, you can adjust the line spacing of figure captions. To additionally decrease the font size, add the following to the YAML front matter:
header-includes:
- \usepackage{setspace}
- \captionsetup[figure]{font={stretch=1,scriptsize}}
This should also make room for bigger captions or taller figures.
I have a big text and like to highlight words that are trademarks. So within this big CDATA node I need to grab for multiple words like "ACME Soda Chips" and make them red.
currently I do something like this in a TinyMCE plugin:
// almost ...
var foo = editor.getContent();
foo.replace('ACME Soda Chips', '<span class="douh">ACME Soda Chips</span>');
editor.setContent(foo);
My problem now is, that such HTML is displayed in Text-Mode (where you see the content as plain HTML) and also submitted therefor stored to the database.
But what I like to have is:
Highlight a word in the visual mode
Do not store my surrounding span somehow
Optional: Do not show that I used a span and CSS-class to highlight things.
Hint:
I may completely do this wrong - please help.
I read some other plugins and honestly I don't understand what they do.
Imagine the whole text as one single big CDATA part but I like to highlight a specific set out of it.
I'm converting some documentation from HTML to github-flavored markdown. I have lots of reddish/pink warning boxes in the old documentation.
e.g.
div.warnbox { background-color:#fcc; border-left: 3px solid #f00; }
~~~~~~
<div class="warnbox">
If you pass null as a parameter the world will end.
</div>
Is there any way to do something similar in (github) markdown? So far I've been using quote boxes which don't come in assertive red:
> If you pass null as a parameter the world will end
I also saw an interesting solution where someone suggested using diff syntax code blocks:
```diff
- If you pass null as a parameter the world will end
```
But that has multiple problems (gray outline, fixed width font, '-' at the beginning of the line, etc)
Is there any way (even if hacky like the diff thing) to do this?
Changing colour is not possible at this time.
If you want to create info or warning boxes, you can do so as of May 2022.
You can use the accessible note or warning blockquote in Markdown
Input:
> **Note**
> This is a note
> **Warning**
> This is a warning
Output Image:
https://github.com/github-community/community/discussions/16925
You can create color text or background in a GitHub markdown file by using diff, to create red and green colors, as in the example:
+ Green Text
- Red Text
Where GitHub markdown file does not support color, even though HTML.
I have found how to do side by side figures for latex export as described here:
http://permalink.gmane.org/gmane.emacs.orgmode/52978
But the problem is that when I try to attach a #+CAPTION or #+NAME / #+LABEL, the output gets garbled with the caption moved across multiple lines as well as the pictures.
#+CAPTION: Some desription.
#+LABEL: mylabel
#+ATTR_LATEX: width=5cm
| [[./test.png]] | [[./test2.png]] |
I tried the same syntax with a single figure and it works fine:
#+CAPTION: Some desription.
#+LABEL: mylabel
#+ATTR_LATEX: width=5cm
[[./test.png]]
Does anyone know how to get this to work?
AFAICT, the hack described in the link above (and I'm allowed to call it that, since I came up with it in the first place :-) ) works in current versions of org (9.0.3+ or thereabouts) with some customizations:
By default, images are centered (so the \includegraphics is wrapped inside a center environment), but that breaks images in tables. In the example below, I turn off the centering using a #+BIND to set org-latex-images-centered to nil.
The #+ATTR_LATEX (which, if I'm not mistaken, should look like this in "modern" org syntax: #+ATTR_LATEX: :width 5cm) applies to the table, so the images get the default size of 0.9\ linewidth, and with two of them, that's more than the width of the page. So in the example below, I use another #+BIND to set the default size of the images, but I think there is a bug: they are not set to 5cm as specified, but to their "natural" size. In any case, even if this is a bug, it is not really germane to the question.
Note that the caption is attached to the table that contains the two images: there might be a way to attach separate captions to the images, but I don't know for sure.
With all that in place, the following example file works for me (and it also shows a way to get a single centered image, even if you've disabled centering globally, as I do with the first #+BIND):
#+BIND: org-latex-images-centered nil
#+BIND: org-latex-image-default-width 5cm
* side by side figures in latex
#+CAPTION: An image
#+NAME: myimage
#+ATTR_LATEX: :width 8cm :center t
[[./images/test1.png]]
#+CAPTION: Some description
#+NAME: mytable
| [[./images/test1.png]] | [[./images/test2.png]] |
EDIT: There is no bug - I made a mistake in the #+BIND - it should be
#+BIND: org-latex-image-default-width "5cm"
The quotes are necessary!
Instead of putting images in a table, I centered a pair of images using this question from the TeX site on StackExchange..
I made a 1x1, transparent pixel at this web site and saved it to a file named empty_fig.png. I told org-mode to make it really tiny with #+ATTR_LATEX: :height 0.0001in. I then captioned that figure, right under the pair that I was not able to caption.
#+begin_center
#+ATTR_LATEX: :height 0.4\textwidth :center nil
[[file:Screenshot from 2019-04-30 18-25-36.png]]
#+ATTR_LATEX: :height 0.4\textwidth :center nil
[[file:Screenshot from 2019-04-30 18-25-46.png]]
#+end_center
#+CAPTION: Example frames
#+LABEL: fig:video_pair
#+ATTR_LATEX: :height 0.0001in
[[file:empty_fig.png]]
I realize that this is hacky and it is exposed to having the image pair separated from the empty image when LaTeX re-flows the page, but that will be a different bridge to cross. It's an alternative that doesn't entail BIND, i.e., changing the internal state variables of org-mode.
Figured out a neat solution inspired by this post:
#+caption: Caption shared by both figures
#+BEGIN_EXPORT html
<img src="./fig1.png" width="48%"> <img src="./fig2.png" width="48%">
#+END_EXPORT
I later realized it only works on Hugo site when displaying as HTML and does not work on a normal org file.