# Centering the cells of a table and the use of tiny size

I change my question to clarify. In the following code (I have integrated the solution for \tiny):

First define a function:

def All_pref(cand=["A", "B", "C", "D"], code=1) :
ncand = len(cand)
Scand = sorted(Set(cand))
all_pref = Arrangements(Scand, ncand).list()
all_pref1 = [str(Word(x)) for x in all_pref]
if code == 1:
return ncand
if code == 2:
return all_pref1


Then use it:

cand = ["A", "B", "C", "D"]
ne1 = [18, 16, 14, 12, 11, 20, 19, 14, 16, 12, 2, 1, 0, 0, 20, 16, 13, 15, 11, 10, 9, 8, 7, 5]
ne = ne1
Ap = All_pref(cand, 2)
cond1 = ['$\\tiny${}{}{}{}$'.format(*w) for w in Ap] cond2 = [""] + [r'${}$'.format(*w) for w in cand] cond3 = [r'${}$'.format(*w) for w in cand] t1 = table([ne], header_row=cond1) rank = [[x.find(l) for x in Ap] for l in cand] score_de_Borda = [[abs(x.find(l) - len(cand)) for x in Ap] for l in cand] t2 = table(rank, header_row=cond1, header_column=cond2) total_score_de_Borda = [add([score_de_Borda[j][i]*ne[i] for i in range(24)]) for j in range(len(cand))] # t3 = table(total_score_de_Borda, header_column=cond3) show(cond3,total_score_de_Borda)  everything works fine apart from the header_column=cond3 (without it I have no problem) and as show(cond3, total_score_de_Borda) shows, the two elements have the same length. edit retag close merge delete ## Comments Sorry I have understud ne1 must be a list of list. ( 2021-01-06 10:13:59 +0200 )edit ## 1 Answer Sort by » oldest newest most voted Regarding the "\tiny doesn't work" part, you should add a $ before the LaTeX formula and you should either escape the \ with another \ or use a raw string:

sage: cond1 = ['$\\tiny{}{}{}{}$'.format(*w) for w in Ap]
sage: cond1 = [r'$\tiny{}{}{}{}$'.format(*w) for w in Ap]


Regarding the table, it needs a list of lists, not just a list, so use extra brackets; and you want headers for the columns, so they form a row of headers or "header row".

sage: t3 = table([total_score_de_Borda], header_row=cond3)
sage: t3
$A$   $B$   $C$   $D$
+-----+-----+-----+-----+
717   691   669   613

more

Ok. For a Latex user it's not self evident.

( 2021-01-06 18:20:58 +0200 )edit