Closed linhduongtuan closed 1 year ago
Hello @linhduongtuan, glad you liked tablex!
Citations inside tables are not possible in the current Typst version (v0.5.0) due to an upstream bug (see #8 for more info). However, this bug will be fixed in the next Typst version (v0.6.0), so, when that is released (probably in a few weeks), citations should begin working normally in tablex!
The #figure function is smart and can detect built-in tables automatically, but not tablex's tables (for now, at least). Due to that, you will need to specify the following additional parameter to #figure: kind: table
, which forces it to see the tablex table inside it as if it were a native table. That way, you will be able to generate a list of tables with #outline(target: table)
. (Regarding this, see also #7.) Hope this helps!
Thank you for swift response. I will try to fix the issue by following your suggestions. Linh
@PgBiel Well, my code is
#counter(page).update(1)
// Chapter counter, record formula hierarchy
#let counter_chapter = counter("chapter")
#let counter_equation = counter(math.equation)
#let counter_image = counter(figure.where(kind: image))
#let counter_table = counter(figure.where(kind: table))
#let counter_tablex = counter(figure.where(kind: tablex))
#let textbf(it) = [
#set text(weight: "semibold")
#it
]
#let textit(it) = [
#set text(style: "italic")
#it
]
// Format of Figures, Tables, and Equatations
#show figure: it => [
#v(6pt)
#set text(font_size.scriptsize)
#set align(center)
#if not it.has("kind") {
it
} else if it.kind == image {
it.body
[
#textbf("Figure")
#locate(loc => {
//[#counter_chapter.at(loc).first().#counter_image.at(loc).first()]
[#counter_image.at(loc).first()]
})
#it.caption
]
} else if it.kind == table {
[
#textbf("Table")
#locate(loc => {
//[#counter_chapter.at(loc).first().#counter_table.at(loc).first()]
[#counter_table.at(loc).first()]
})
#it.caption
]
it.body
} else if it.kind == tablex {
[
#textbf("Table")
#locate(loc => {
//[#counter_chapter.at(loc).first().#counter_tablex.at(loc).first()]
[#counter_tablex.at(loc).first()]
})
#it.caption
]
it.body
} else {
it.body
}
#v(6pt)
]
#figure(
tablex(
columns: 6,
align: center + horizon,
auto-vlines: false,
repeat-header: true,
header-rows: 2,
/* --- header --- */
rowspanx(2)[*Type*], rowspanx(2)[*Original Task*], colspanx(3)[*Categorys*], (), rowspanx(2)[*Total*],
(), [*Benign*], [*Malignant*], [*Normal*], (),
/* -------------- */
//vlinex(), vlinex(), vlinex(), vlinex(), vlinex(), vlinex(),
[Lin], [Object detection], [9,932], [15,475], [0], [25,407], hlinex(stroke: none), //remove the horizon line
[Al-Dhabyani], [Segmentation], [437], [210], [133], [780], hlinex(stroke: none),
[Rodrigues], [Not applicable], [100], [150], [0], [250],
[*Total*], [---], cellx(fill: gray)[10,469], cellx(fill: aqua, text(fill: red, weight: "bold", [15835])), cellx(fill: teal, text(fill: red, weight: "bold", [133])), cellx(fill: rgb("#b1f2eb"), text(fill: rgb(25%, 13%, 65%), weight: "bold", [26,437]))),
caption: [Collection data used in this study]
)<tab-XXX>
However, the legend still appears as Figure
instead of Table
. In other word, it seems that tablex
is being recognized as Figure?
Do you have any ideas for this issue?
Linh
However, the legend still appears as
Figure
instead ofTable
. In other word, it seems thattablex
is being recognized as Figure? Do you have any ideas for this issue? Linh
Oh, sorry, I should have been clearer; you will have to replace your
#figure(
tablex(
columns: 6,
align: center + horizon,
auto-vlines: false,
repeat-header: true,
header-rows: 2,
/* --- header --- */
rowspanx(2)[*Type*], rowspanx(2)[*Original Task*], colspanx(3)[*Categorys*], (), rowspanx(2)[*Total*],
(), [*Benign*], [*Malignant*], [*Normal*], (),
/* -------------- */
//vlinex(), vlinex(), vlinex(), vlinex(), vlinex(), vlinex(),
[Lin], [Object detection], [9,932], [15,475], [0], [25,407], hlinex(stroke: none), //remove the horizon line
[Al-Dhabyani], [Segmentation], [437], [210], [133], [780], hlinex(stroke: none),
[Rodrigues], [Not applicable], [100], [150], [0], [250],
[*Total*], [---], cellx(fill: gray)[10,469], cellx(fill: aqua, text(fill: red, weight: "bold", [15835])), cellx(fill: teal, text(fill: red, weight: "bold", [133])), cellx(fill: rgb("#b1f2eb"), text(fill: rgb(25%, 13%, 65%), weight: "bold", [26,437]))),
caption: [Collection data used in this study]
)<tab-XXX>
with
#figure(
kind: table, // <----- here!
tablex(
columns: 6,
align: center + horizon,
auto-vlines: false,
repeat-header: true,
header-rows: 2,
/* --- header --- */
rowspanx(2)[*Type*], rowspanx(2)[*Original Task*], colspanx(3)[*Categorys*], (), rowspanx(2)[*Total*],
(), [*Benign*], [*Malignant*], [*Normal*], (),
/* -------------- */
//vlinex(), vlinex(), vlinex(), vlinex(), vlinex(), vlinex(),
[Lin], [Object detection], [9,932], [15,475], [0], [25,407], hlinex(stroke: none), //remove the horizon line
[Al-Dhabyani], [Segmentation], [437], [210], [133], [780], hlinex(stroke: none),
[Rodrigues], [Not applicable], [100], [150], [0], [250],
[*Total*], [---], cellx(fill: gray)[10,469], cellx(fill: aqua, text(fill: red, weight: "bold", [15835])), cellx(fill: teal, text(fill: red, weight: "bold", [133])), cellx(fill: rgb("#b1f2eb"), text(fill: rgb(25%, 13%, 65%), weight: "bold", [26,437]))),
caption: [Collection data used in this study]
)<tab-XXX>
Note that you can also specify kind: "tablex"
if you want to distinguish tablex tables from default tables (but that's not necessary, in principle).
@PgBiel,
Thank you so much.
It does work for my case with kind: table,
but does not work if you set either kind: "tablex",
or kind: tablex,
.
However, everything is running fine now.
Linh
Hey @linhduongtuan , glad you got it to work!
Just to note that, if you go with the kind: "tablex",
approach, you will also have to write supplement: [Table]
(or similar) to go with it :wink: .
Feel free to ask more questions if needed! Closing the issue now.
Dear @PgBiel, Thank you for creating the fascinating repository. I have a couple of questions. Firstly, I would like to know how to include citations within a table. Secondly, I'm interested in how to generate a List of Tables.
Regarding the first question, if I use the built-in function #table within the #figure function, I can create a List of Tables. However, I haven't yet figured out how to generate the List.
Thank in advance Linh