#Downscale a table / code blocks

98 messages · Page 1 of 1 (latest)

winter grotto
#

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.

untold oxide
#

scale(..for k in ("x", "y") {((k): 60%)}, reflow: true, …)

winter grotto
untold oxide
cyan tiger
#

do you only want to change the font size or the whole table's / code block's size

untold oxide
#

text(.6em, …)

rocky portal
#

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.

rocky portal
#

which is likely the intended outcome

untold oxide
#

?r ps=d

#scale(60%, reflow: true, table(columns: 2 * (1fr,))[A][B])
#scale(x: 60%, reflow: true, table(columns: 2 * (1fr,))[A][B])
#text(.6em, table(columns: 2 * (1fr,))[A][B])
untold oxide
winter grotto
#

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>

cyan tiger
#

as has already been said, it's probably better to just do the scaling manually by reducing the text size, changing the inset etc.

winter grotto
#

So, using just text(.6em, …) ?

#

where the ... is the entire table?

cyan tiger
#

either that or

#{
  set text(.6em)
  …
}
#

… is the entire table yes

winter grotto
#

Let me try that really quick ty

cyan tiger
#

?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>

cyan tiger
#

block isn't needed if you don't want to restrict its width

#

oh wait that changes the font size for the caption lmao

winter grotto
#

Yea that seems like what I am trying to achive (although the caption of the figure shouildnt shrink)

cyan tiger
#

should be limited to the table

#

sec

#

uh oh

#

there we go

#

forgot a #

winter grotto
#

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

cyan tiger
#

?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?
cyan tiger
#

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

rocky portal
#

you can use #show table: set text(...) To restrict it to the table

rocky portal
#

So you'd have like (0pt, 0pt, ..., 3pt, 0pt)

winter grotto
#

That should work fine for what I want 🙂

winter grotto
#

@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

rocky portal
#

you will have to change the widths of the columns

#

theres no other way to make the table larger

winter grotto
#

They are all set to auto

rocky portal
#

yeah you'll have to change that

untold oxide
#

columns: n * (1fr,)

rocky portal
#

you can use fractional columns so they occupy proportional space within 100% (equal space if they are all 1fr)

winter grotto
#

I am not sure how I would do that

rocky portal
#

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

winter grotto
#

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?

rocky portal
#

maybe

#

you will have to play with the values to see what looks best

untold oxide
#

Why not leave that one auto?

rocky portal
#

that also works

#

but could look off compared to the others

winter grotto
#

I guess I try and see what works

rocky portal
#

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

winter grotto
#

Nice it worked pretty well 🙂 I did auto 1fr 1fr 1fr

winter grotto
rocky portal
#

yes

#

of the available width to be more precise (so, not always 100% since some width might be occupied by other columns or text)

untold oxide
rocky portal
untold oxide
rocky portal
#

well

#

i cant think of a use case for that

#

but you can use colspans

untold oxide
#

So things look equally ‘spacy’.

rocky portal
#

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

untold oxide