Normally, when I create a table or a code block, it will use the same font size that is used for the rest of the document. Is it possible to downscale a specific table / code block - aka have everything contained in that segment (font, formulas, other structures) be only be 60% of what the normal text document size is? I have some tables and some code blocks that are very information-dense, and I can't format them nicely, if they use the same font-size as the rest of the document.
#Downscale a table / code blocks
98 messages · Page 1 of 1 (latest)
scale(..for k in ("x", "y") {((k): 60%)}, reflow: true, …)
Thanks for the reply. Would I just have to put this before the segment I want to scale? e.g. the table?
… in there is the corresponding placeholder.
do you only want to change the font size or the whole table's / code block's size
text(.6em, …)
that for with spread is really overkill 😂
scale(x: 60%, y: 60%, reflow: true, table here)
likely much clearer :p
but yeah that will scale not only the text but also the lines, images etc.
this will only scale the text
which is likely the intended outcome
?r ps=d
[0m[3m[34m#scale[0m([0m[33m60%[0m, reflow: [0m[35mtrue[0m, [0m[3m[34mtable[0m(columns: [0m[33m2[0m [0m[36m*[0m ([0m[33m1fr[0m,))[A][B])
[0m[3m[34m#scale[0m(x: [0m[33m60%[0m, reflow: [0m[35mtrue[0m, [0m[3m[34mtable[0m(columns: [0m[33m2[0m [0m[36m*[0m ([0m[33m1fr[0m,))[A][B])
[0m[3m[34m#text[0m([0m[33m.6em[0m, [0m[3m[34mtable[0m(columns: [0m[33m2[0m [0m[36m*[0m ([0m[33m1fr[0m,))[A][B])
I suspected there being a positional shortcut argument, but I was on a phone & timely restricted, so I typed the variant without variable assignment or value duplication.
I tried this, but it completly breaks the formatting of the table for me:
I tried this:
#show table: set par(justify: false)
#figure(
scale(x: 60%, y: 60%, reflow: true,
table(
columns: (auto, auto, auto, auto, auto),
inset: 10pt,
align: horizon,
table.header(
[], [*Server RTT Cap Req (μs)*], [*Server RTT Update (μs)*], [*PECU RTT Cap Req (μs)*], [*PECU RTT Update (μs)*],
),
[*Iter \#1*],
[238030],
[102600],
[203776],
[100826],
[*Iter \#2*],
[251734],
[73032],
[186422],
[69833],
[*Iter \#3*],
[268954],
[92519],
[202707],
[91186],
[*Iter \#4*],
[261580],
[103120],
[195952],
[101744],
[*Iter \#5*],
[259867],
[103601],
[195297],
[101729],
[*Iter \#6*],
[258502],
[98653],
[197666],
[94851],
[*Iter \#7*],
[246145],
[75152],
[180621],
[73250],
[*Iter \#8*],
[253141],
[101261],
[188281],
[99034],
[*Iter \#9*],
[256279],
[99322],
[198615],
[97128],
[*Iter \#10*],
[259794],
[99879],
[195638],
[97009],
[*Std. Div.*],
[8676],
[11427],
[7310],
[11622],
[*Std. Err.*],
[2743],
[3613],
[2311],
[3675],
),
),
caption: [
asdfasd
]
)<fig-tbl-scenario2>
as has already been said, it's probably better to just do the scaling manually by reducing the text size, changing the inset etc.
Let me try that really quick ty
?r ```
#lorem(50)
#figure({
set text(.6em)
table(
columns: (auto, auto, auto, auto, auto),
inset: 5pt,
align: horizon,
table.header(
[], [Server RTT Cap Req (μs)], [Server RTT Update (μs)], [PECU RTT Cap Req (μs)], [PECU RTT Update (μs)],
),
[Iter #1],
[238030],
[102600],
[203776],
[100826],
[Iter #2],
[251734],
[73032],
[186422],
[69833],
[Iter #3],
[268954],
[92519],
[202707],
[91186],
[Iter #4],
[261580],
[103120],
[195952],
[101744],
[Iter #5],
[259867],
[103601],
[195297],
[101729],
[Iter #6],
[258502],
[98653],
[197666],
[94851],
[Iter #7],
[246145],
[75152],
[180621],
[73250],
[Iter #8],
[253141],
[101261],
[188281],
[99034],
[Iter #9],
[256279],
[99322],
[198615],
[97128],
[Iter #10],
[259794],
[99879],
[195638],
[97009],
[Std. Div.],
[8676],
[11427],
[7310],
[11622],
[Std. Err.],
[2743],
[3613],
[2311],
[3675],
)},
caption: [asdfasd]
)<fig-tbl-scenario2>
block isn't needed if you don't want to restrict its width
oh wait that changes the font size for the caption lmao
Yea that seems like what I am trying to achive (although the caption of the figure shouildnt shrink)
Thanks that seems to do the trick.
A quick side question: Do you know if there is a way to have a small space between the last two rows to provide a bit of visual separation?
so that std devitation and std error stand out a bit
?r t=l ```
#figure({
set text(.6em)
table(
columns: (auto, auto, auto, auto, auto),
inset: 5pt,
align: horizon,
table.header(
[], [Server RTT Cap Req (μs)], [Server RTT Update (μs)], [PECU RTT Cap Req (μs)], [PECU RTT Update (μs)],
),
[Iter #1],
[238030],
[102600],
[203776],
[100826],
[Iter #2],
[251734],
[73032],
[186422],
[69833],
[Iter #3],
[268954],
[92519],
[202707],
[91186],
[Iter #4],
[261580],
[103120],
[195952],
[101744],
[Iter #5],
[259867],
[103601],
[195297],
[101729],
[Iter #6],
[258502],
[98653],
[197666],
[94851],
[Iter #7],
[246145],
[75152],
[180621],
[73250],
[Iter #8],
[253141],
[101261],
[188281],
[99034],
[Iter #9],
[256279],
[99322],
[198615],
[97128],
[Iter #10],
[259794],
[99879],
[195638],
[97009],
table.cell(colspan: 5, stroke: none, inset: 3pt, {}),
[Std. Div.],
[8676],
[11427],
[7310],
[11622],
[Std. Err.],
[2743],
[3613],
[2311],
[3675],
)},
caption: [asdfasd]
)<fig-tbl-scenario2>
Do you mean something like this?
there's probably a better way I'm just a bit ignorant
gutter, row-gutter and column-gutter don't seem to take a function
you can use #show table: set text(...) To restrict it to the table
correct, they take arrays though
So you'd have like (0pt, 0pt, ..., 3pt, 0pt)
yes thats what I meant
That should work fine for what I want 🙂
@rocky portal is there a way to allow the table to take 100% of the width in the previously described scenario, even if the columns dont need it?
E.g. I have this:
table at the bottom doesnt take full page width because it theoretically gets by with less but it looks odd in the context of my document
So I was thinking it would be nice if the table would take still 100% width
you will have to change the widths of the columns
theres no other way to make the table larger
They are all set to auto
yeah you'll have to change that
columns: n * (1fr,)
you can use fractional columns so they occupy proportional space within 100% (equal space if they are all 1fr)
I am not sure how I would do that
it's a unit
fr
like cm
but it has a special meaning
if you have three columns of width 1fr, typst will take the total width available - let's say it's 300cm - and divide it by the sum of fractional points (in this case 1fr + 1fr + 1fr = 3fr, which will give us 300 / 3 = 100cm)
that will be the size of 1fr (in this case 100cm = 1fr)
then each column will be assigned 100cm * (amount of fr) in this example
so
if u have a 1fr column and a 2fr column, the first one will take 1/3 of the total available width, while the second one will take 2/3
if u have 3 1fr columns they will all have 1/3
So in my case, i have one column that sticks out as needing more space then the others: the left one
so I assume I would do 2fr, 1fr, 1fr, 1fr?
something like that?
Why not leave that one auto?
I guess I try and see what works
basically , if at least one column uses fr units, the table will occupy 100% of the width
the available space is shared between each column with fr units according to the proportion you define
other columns arent affected
note that fr units also work with rows
though it's a bit more flaky to use for rows
Nice it worked pretty well 🙂 I did auto 1fr 1fr 1fr
I see, thats good to know, because it always takes a fraction of the full width?
yes
of the available width to be more precise (so, not always 100% since some width might be occupied by other columns or text)
A shame table(columns: (1fr + auto, 2fr))[a][b] isn't supported.
what would this do?
(measure[a].width + 1fr, 2fr)
^
So things look equally ‘spacy’.
that wouldnt be the case here
it would look much larger
something like this
either way, well
it's already possible through colspans so u can use that in the off-chance u really need it
You'd have to play with the fr proportions.