Tables and axes > Creating tables > Combining tables > Adding tables > Offsets with added tables
 
Offsets with added tables
Tables to be added can be offset by any number of rows or columns; that is, the table defined by add can be shifted a number of columns to the right or down a given number of rows before the cells are added. For example, you might want to add cell 2 of row 3 in the first table to cell 1 of row 1 in the second table. This is an offset of 2 columns and 3 rows.
To offset a table by a given number of columns, the add statement must be entered as:
addn axis1 axis2
where n is the number of columns towards the right that the table is to be shifted before it is added to the tab table. There is no space between the keyword add and the offset. So,
tab ax01 bk01
add3 ax02 bk02
shifts the second table three columns to the right before adding it to the first table: column 3, row 1 of ‘ax01 by bk01’ is added to column 1, row 1 of ‘ax02 by bk02’, and so on.
To add tables with vertical offsets, the notation is:
addm,0 axis1 axis2 ... [axis6]
where m is the number of rows to offset. When doing this, you must be sure to enter a zero for the column offset otherwise Quantum will combine the tables horizontally instead. A single number after add is assumed to be a column offset:
add5 ax01 bk01 has an offset of 5 columns
add5,0 ax01 bk01 has an offset of 5 rows
To define row and column offsets for the same table, write:
addm,n axis1 axis2 ... [axis6]
where m is the row offset and n is the column offset. If the row or column axis contains an n25 statement, remember that it creates three elements even though none of them are printed in the table.
A tab statement can be followed by any number of adds with the same or varying offsets.
Note Offsets are always based on the tab table rather than on the intermediate adds themselves.
For example:
tab ax01 bk01
add2 ax02 bk02
add2,1 ax03 bk03
takes the table ax02 by bk02, offsets it by 2 columns and adds it to the tab table. Then the table ax03 by bk03 is offset by 2 rows and 1 column and added to the tab table. To clarify this further, the tables shown below are the individual tables before adding takes place:
ax01 by bk01
c1 c2 c3 c4 c5
r1 12 9 3 0 0
r2 6 4 2 0 0
r3 6 5 1 0 0
r4 0 0 0 0 0
r5 0 0 0 0 0
ax02 by bk02 ax03 by bk03
c1 c2 c3 c1 c2 c3
r1 7 2 5 r1 5 4 1
r2 3 2 1 r2 4 3 1
r3 4 0 4 r3 1 1 0
Adding the first add table (ax02 by bk02) to the tab gives:
c1 c2 c3 c4 c5
r1 12 9 10 2 5
r2 6 4 5 2 1
r3 6 5 5 0 4
r4 0 0 0 0 0
r5 0 0 0 0 0
This table is only temporary and it is never printed, but the numbers in column 3 are the sum of the numbers in column 3 of table 1 and column 1 in table 2.
The next step is to add the table created by the second add to this temporary table. Remember that the offsetting is based on the original table rather than the previous add, so, ignoring the row offset for the moment, we add column 1 of table 3 to column 2 of table 1, which is also column 2 of the temporary table. The row offset is 2, so row 1 of the third table is added to row 3 of the first table.
The final printed table is as follows:
c1 c2 c3 c4 c5
r1 12 9 10 2 5
r2 6 4 5 2 1
r3 6 10 9 1 4
r4 0 4 3 1 0
r5 0 1 1 0 0
The number 9 in r3c3 is the sum of table 1 r3c3, table 2 r3c1 and table 3 r1c2; that is, 1+4+4=9.
See also
Adding tables