I am new to LaTeX and I have to say that I am really struggling with this. I found the \ newcommand command, which is similar to a function / method in common programming languages. You can give him arguments and that’s it.
I was wondering if I can somehow repeat in LaTeX? Basically, I would like to create a table with N + 1 columns, where the first row simply contains an empty cell, and then the numbers 1, 2, ..., N in other columns. I just want to give N as an argument to this "function" (newcommand).
Here is an example of what might look like what I'm looking for (although obviously this will not work):
\ newcommand {\ mytable} [2] {
\ begin {tabular} {l | * {# 1} {c |}}% table with first argument + 1 columns
for (int i = 1; i <= # 1; i ++) "& i"% 'output' numbers in different columns
\\\ hline
letters & # 2% second argument should contain actual content for row
\\\ hline
\ end {tabular}
}
Call the following address:
\ mytable {3} {a & b & c}
The conclusion should be:
| 1 | 2 | 3 |
-------- + --- + --- + --- +
letters | a | b | c |
-------- + --- + --- + --- +
Does anyone know if something like this is possible?
Thanks!
source
share