In certain cases, I need such functions to do homework, e.g. when using array method for discrete convolution computations, like in the following pic,
is it possible, or do I need to insert a photo in this case?
In certain cases, I need such functions to do homework, e.g. when using array method for discrete convolution computations, like in the following pic,
You could definitely write it out using a table, and probably automate the layout into a function. I’m not familiar enough with the mathematical methods to be able to suggest a way to actually carry out the calculations.
I’ll try and get an example of the layout in a bit though.
Here you go:
#table(
columns: 8,
align: (x, y) => if x == 7 {left} else {center},
stroke: none,
$6$,$5$,$4$,$3$,$2$,$1$,$0$,
table.vline(),
$n$,
table.hline(),
[],[],[],$-4$,$3$,$-2$,$1$,$v(n)$,
[],[],[],$-1$, [], $1$, $4$, $x(n)$,
table.hline(),
[],[],[],$-16$,$12$,$-8$,$4$, [],
[],[], $-4$, $3$, $-2$, $1$, [], [],
$4$, $-3$, $2$, $-1$, [],[],[], [],
table.hline(),
$4$, $-3$, $-2$, $-14$, $10$, $-7$, $4$, $w(n) = v(n) * x(n)$
)
this looks so refined and cool!! I was trying to achieve something similar using grid. You have shown me that table can achieve a lot, thanks a lot!!
Note that a grid has the same capabilities; you could replace table
with grid
in their example and add inset: 5pt
(the default inset for tables) and it’d look exactly the same!
The difference is mostly semantic: grids are used only for layout purposes, while tables tend to be proper figures in your document following the usual table model (with a table header and so on). Here, a grid would likely make more sense since we’re using its capabilities for layout purposes.
The other difference is that a table has a default of stroke: black + 1pt
and inset: 5pt
, whereas a grid has a default of stroke: none
and inset: 0pt
. But you can just change one to the other at will.
For more information, take a look at the following pages from the docs: