Open jjallaire opened 2 years ago
another/further suggestion: make the table/figure labelling/x-ref framework extensible, so that users can define new numbered objects (theorem, lemma, definition, algorithm etc), numbering style and section/chapter nesting options a la LaTeX
. Or is this already possible?
Thanks, yes, more extensibility is definitely in order. There are some options currently available to customize numbering styles and labels: https://quarto.org/docs/authoring/cross-references.html#options
Just would like to make some corrections. I don't consider the "text layout" suggestions worth implementing anymore. I realise that every time I render something as HTML, I create a .css
file anyway and it's just as easy to center and justify things in the .css
directly.
What I could add to the suggestions would be to have an option to prepend nocite
references to the bibliography instead of adding them after cited refs (see #1183). This is a requirement for some journals to have the list of all references in the appendix so that could definitely be useful. Not sure if should understand the answer on the thread as "this isn't possible" though, in which case just ignore the suggestion.
@jjallaire I have a requirement. When number-sections: true
is turned on, I want to generate a format like Figure 1-1
instead of Figure 1.1
. What should I do for pdf and gfm output?
We don't currently have an option for that but will definitely do so when we work on other improvements to crossrefs (should be in the next couple of releases)
Was there a solution to a space between a title and a number, when using fig-title: "Figure S"
? So that the output would be Figure S1
, instead of Figure S 1
.
@perechen In the meantime, you can use some LaTeX commands:
---
format:
pdf:
include-in-header:
text: |
\usepackage{caption}
\DeclareCaptionLabelFormat{fig}{
\textbf{#1 S#2}
}
\captionsetup[figure]{
labelformat=fig
}
---
#1
corresponds to the figure title while #2
is the figure number.
You can also save the LaTeX commands in a file (e.g. styles.tex
) and import it.
---
format:
pdf:
include-in-header: styles.tex
---
@perechen @arnaudgallou: Is there a workaround for the space between a title and number that will work when knitting to Microsoft Word? Here's the YAML header for my document where I'm commandeering the cor and lem crossrefs for my supplemental tables and figures, but end up with, e.g., "Table S 1" instead of "Table S1".
---
title: "Title"
format:
docx:
reference-doc: word-style-reference-manuscript.docx
execute:
echo: false
warning: false
crossref:
thm-title: "Table"
thm-prefix: "Table"
cor-title: "Table S"
cor-prefix: "Table S"
lem-title: "Figure S"
lem-prefix: "Figure S"
---
Are there plans to add left and right justification options for figure captions as suggested by the OP? I have seen some suggestions for how to do this with custom CSS but cannot find a good LaTeX solution. For example, I tried the caption package and it aligns the caption to the edge of the page rather than the edge of the image, e.g.
header-includes:
- \usepackage{caption}
- \captionsetup{justification = raggedright, singlelinecheck = false, skip = 0 pt}
Are there plans to add left and right justification options for figure captions as suggested by the OP?
The problem with a direct implementation of this request is that the number of possible requests is infinite. What the new crossref system will offer is a way to render a crossreferenceable artifact in whatever way you see fit.
We still need to write up proper documentation for this, but the code will, more or less, look like this. Don't take this as documentation, just as a preview of how to do it:
-- my_custom_figure_renderer.lua
quarto._quarto.ast.add_renderer("FloatRefTarget", function(float)
-- return true if you want to handle this specific float. In a renderer that replaces our default renderer, you'll probably
-- want this to just "return true"
end, function(float)
-- render your figure here, however you want. `float` is a Lua table with fields like `caption_long`, `content`, `identifier`, etc.
local result = pandoc.Blocks({
pandoc.RawInline("latex", "\begin{myfancyfigure}[myoptions]"),
pandoc.RawInline("latex", "\mycustomcaption{\label{" .. float.identifier .. "}")
})
result.insert(float.caption_long)
-- etc etc
return result
end)
We'll have simple examples in our docs, but this is how it's going to be done. Header includes, etc, will be handled just like before.
Part of this is now done in main
, but the part that involves control over how the references themselves are rendered will be done in 1.5.
Discussed in https://github.com/quarto-dev/quarto-cli/discussions/1088