How to draw a Cayley table










12















I'm trying to make a Cayley table like the one in the following question, but I don't want the labels, for example, on top (Capacity) and on the left side (the w's and v's). I just would like to reproduce the exact same table without the 'extra' bits on the side.



I forgot to mention I want a 5x5 table (25 entries inside the table), but still with the "outer" headings.



I managed to do this. However, this is long-winded I think:



[
begintabular>$l<$
~ & 1 & a & a^2 & a^3 & a^4 \
hlinevrule height 12pt width 0pt
1 & 1 & a & a^2 & a^3 & a^4 \
a & a & a^2 & a^3 & a^4 & a^5 \
a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
endtabular
]


EDIT:



setlengthextrarowheight3pt
noindentbegintabular c c c c c

& 1 & a & a^2 & a^3 & a^4 \
cline1-6
1 & 1 & a & a^2 & a^3 & a^4 \
a & a & a^2 & a^3 & a^4 & a^5 \
a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
endtabular









share|improve this question
























  • the answer provided was excellent in the above link, I would appreciate if I can get a similar answer.

    – A.E
    Nov 12 '18 at 15:36






  • 3





    Just take Gonzalo's answer and delete first line (the one which contains Capacity) and two left columns and two right ones.

    – Ignasi
    Nov 12 '18 at 15:47






  • 1





    array, not tabular.

    – egreg
    Nov 12 '18 at 16:03






  • 1





    You Need to put $a^2$ when you want to use math!

    – GiuTeX
    Nov 12 '18 at 16:19






  • 1





    @A.E As it is, the added code produces tons of errors.

    – egreg
    Nov 12 '18 at 16:19















12















I'm trying to make a Cayley table like the one in the following question, but I don't want the labels, for example, on top (Capacity) and on the left side (the w's and v's). I just would like to reproduce the exact same table without the 'extra' bits on the side.



I forgot to mention I want a 5x5 table (25 entries inside the table), but still with the "outer" headings.



I managed to do this. However, this is long-winded I think:



[
begintabular>$l<$
~ & 1 & a & a^2 & a^3 & a^4 \
hlinevrule height 12pt width 0pt
1 & 1 & a & a^2 & a^3 & a^4 \
a & a & a^2 & a^3 & a^4 & a^5 \
a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
endtabular
]


EDIT:



setlengthextrarowheight3pt
noindentbegintabular c c c c c

& 1 & a & a^2 & a^3 & a^4 \
cline1-6
1 & 1 & a & a^2 & a^3 & a^4 \
a & a & a^2 & a^3 & a^4 & a^5 \
a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
endtabular









share|improve this question
























  • the answer provided was excellent in the above link, I would appreciate if I can get a similar answer.

    – A.E
    Nov 12 '18 at 15:36






  • 3





    Just take Gonzalo's answer and delete first line (the one which contains Capacity) and two left columns and two right ones.

    – Ignasi
    Nov 12 '18 at 15:47






  • 1





    array, not tabular.

    – egreg
    Nov 12 '18 at 16:03






  • 1





    You Need to put $a^2$ when you want to use math!

    – GiuTeX
    Nov 12 '18 at 16:19






  • 1





    @A.E As it is, the added code produces tons of errors.

    – egreg
    Nov 12 '18 at 16:19













12












12








12


4






I'm trying to make a Cayley table like the one in the following question, but I don't want the labels, for example, on top (Capacity) and on the left side (the w's and v's). I just would like to reproduce the exact same table without the 'extra' bits on the side.



I forgot to mention I want a 5x5 table (25 entries inside the table), but still with the "outer" headings.



I managed to do this. However, this is long-winded I think:



[
begintabular>$l<$
~ & 1 & a & a^2 & a^3 & a^4 \
hlinevrule height 12pt width 0pt
1 & 1 & a & a^2 & a^3 & a^4 \
a & a & a^2 & a^3 & a^4 & a^5 \
a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
endtabular
]


EDIT:



setlengthextrarowheight3pt
noindentbegintabular c c c c c

& 1 & a & a^2 & a^3 & a^4 \
cline1-6
1 & 1 & a & a^2 & a^3 & a^4 \
a & a & a^2 & a^3 & a^4 & a^5 \
a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
endtabular









share|improve this question
















I'm trying to make a Cayley table like the one in the following question, but I don't want the labels, for example, on top (Capacity) and on the left side (the w's and v's). I just would like to reproduce the exact same table without the 'extra' bits on the side.



I forgot to mention I want a 5x5 table (25 entries inside the table), but still with the "outer" headings.



I managed to do this. However, this is long-winded I think:



[
begintabular>$l<$
~ & 1 & a & a^2 & a^3 & a^4 \
hlinevrule height 12pt width 0pt
1 & 1 & a & a^2 & a^3 & a^4 \
a & a & a^2 & a^3 & a^4 & a^5 \
a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
endtabular
]


EDIT:



setlengthextrarowheight3pt
noindentbegintabular c c c c c

& 1 & a & a^2 & a^3 & a^4 \
cline1-6
1 & 1 & a & a^2 & a^3 & a^4 \
a & a & a^2 & a^3 & a^4 & a^5 \
a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
endtabular






tables






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '18 at 23:09









Peter Mortensen

54736




54736










asked Nov 12 '18 at 15:30









A.EA.E

15211




15211












  • the answer provided was excellent in the above link, I would appreciate if I can get a similar answer.

    – A.E
    Nov 12 '18 at 15:36






  • 3





    Just take Gonzalo's answer and delete first line (the one which contains Capacity) and two left columns and two right ones.

    – Ignasi
    Nov 12 '18 at 15:47






  • 1





    array, not tabular.

    – egreg
    Nov 12 '18 at 16:03






  • 1





    You Need to put $a^2$ when you want to use math!

    – GiuTeX
    Nov 12 '18 at 16:19






  • 1





    @A.E As it is, the added code produces tons of errors.

    – egreg
    Nov 12 '18 at 16:19

















  • the answer provided was excellent in the above link, I would appreciate if I can get a similar answer.

    – A.E
    Nov 12 '18 at 15:36






  • 3





    Just take Gonzalo's answer and delete first line (the one which contains Capacity) and two left columns and two right ones.

    – Ignasi
    Nov 12 '18 at 15:47






  • 1





    array, not tabular.

    – egreg
    Nov 12 '18 at 16:03






  • 1





    You Need to put $a^2$ when you want to use math!

    – GiuTeX
    Nov 12 '18 at 16:19






  • 1





    @A.E As it is, the added code produces tons of errors.

    – egreg
    Nov 12 '18 at 16:19
















the answer provided was excellent in the above link, I would appreciate if I can get a similar answer.

– A.E
Nov 12 '18 at 15:36





the answer provided was excellent in the above link, I would appreciate if I can get a similar answer.

– A.E
Nov 12 '18 at 15:36




3




3





Just take Gonzalo's answer and delete first line (the one which contains Capacity) and two left columns and two right ones.

– Ignasi
Nov 12 '18 at 15:47





Just take Gonzalo's answer and delete first line (the one which contains Capacity) and two left columns and two right ones.

– Ignasi
Nov 12 '18 at 15:47




1




1





array, not tabular.

– egreg
Nov 12 '18 at 16:03





array, not tabular.

– egreg
Nov 12 '18 at 16:03




1




1





You Need to put $a^2$ when you want to use math!

– GiuTeX
Nov 12 '18 at 16:19





You Need to put $a^2$ when you want to use math!

– GiuTeX
Nov 12 '18 at 16:19




1




1





@A.E As it is, the added code produces tons of errors.

– egreg
Nov 12 '18 at 16:19





@A.E As it is, the added code produces tons of errors.

– egreg
Nov 12 '18 at 16:19










5 Answers
5






active

oldest

votes


















9














Basically I've just taken the answer to the question you linked and changed few lines to adapt to your needs.



Here's the code, followed by the output you will get and a brief explanation of what's going on.



The code below produces 2 tables, in one there's written ANYTHING in the top left corner, in the second one there's a white space (just don't put anything in the column "argument".



documentclass[10pt]article
usepackagearray

begindocument

setlengthextrarowheight3pt
noindentbegintabular c c c c c
ANYTHING & 0 & 1 & 2 & 3 & 4 \
cline1-6
0 & 0 & 0 & 0 & 0 & 0 \
1 & 0 & 0 & $a^2$ & 25 & 25 \
2 & $a^2$ & 0 & 20 & 25 & 25 \
2 & 0 & $a^2$ & 20 & 25 & 25 \
2 & 0 & 0 & 20 & 25 & 25 \
endtabular


noindentbegintabular c c c c c
& 0 & 1 & 2 & 3 & 4 \
cline1-6
0 & 0 & 0 & 0 & 0 & 0 \
1 & 0 & 0 & $a^2$ & 25 & 25 \
2 & $a^2$ & 0 & 20 & 25 & 25 \
2 & 0 & $a^2$ & 20 & 25 & 25 \
2 & 0 & 0 & 20 & 25 & 25 \
endtabular

enddocument


enter image description hereenter image description here



How does it work? A table is done with the environment tabular, which requires as argument the numer of columns (or rows... just read the documentation to know more) which is specified by the argument c c c c c: 6 columns divided by a line between the first and the second col. The 'c' stands for centered meaning that the column will be aligned to the center, if you want you can change it to l (left) or r (right).



Then in the tables all the entries are done by spacing them with &, and the cline takes as argument the number of columns that you want it to span: from column 1 to column 6.



The command setlengthextrarowheight3pt adds some extra row height (how surprising!).



Package array is needed for the length extrarowheight.






share|improve this answer




















  • 1





    this is good however I wanted a 5x5 table

    – A.E
    Nov 12 '18 at 16:00






  • 1





    Cheers pal, much appreciated.

    – A.E
    Nov 12 '18 at 16:02






  • 1





    if you could briefly explain what you did line by line, It would be more beneficial so I know what you've done

    – A.E
    Nov 12 '18 at 16:03






  • 1





    much appreciated

    – A.E
    Nov 12 '18 at 16:11











  • I added more on the meaning of the c's in tabular environment.

    – GiuTeX
    Nov 12 '18 at 16:12


















12














Your input is almost good, but you can do better.



documentclassarticle
usepackageamsmath
usepackagearray

begindocument

This is a Cayley table
[
beginarray*5l
& 1 & a & a^2 & a^3 & a^4 \
hline
1 & 1 & a & a^2 & a^3 & a^4 \
a & a & a^2 & a^3 & a^4 & a^5 \
a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
endarray
]

This is the same, but with some more spacing,
[
setlengthextrarowheight3pt% local setting
beginarray*5l
& 1 & a & a^2 & a^3 & a^4 \
hline
1 & 1 & a & a^2 & a^3 & a^4 \
a & a & a^2 & a^3 & a^4 & a^5 \
a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
endarray
]

enddocument


With array, each cell is assumed to be in math mode. The setting of extrarowheight will not propagate to other instances of array, because [...] forms a group.



enter image description here






share|improve this answer




















  • 1





    I prefer the method above as it is easier to follow(in my eyes anyway) but thanks for your answer

    – A.E
    Nov 12 '18 at 16:16







  • 1





    What does * in l|* mean?

    – manooooh
    Nov 12 '18 at 16:17






  • 2





    @manooooh *6l is short for llllll

    – samcarter
    Nov 12 '18 at 16:18






  • 3





    @manooooh The * refers to the following: *6l means “repeat l six times”.

    – egreg
    Nov 12 '18 at 16:18











  • @jfbu Right, fixed

    – egreg
    Nov 12 '18 at 16:47


















10














Some automatizing is in order here



documentclassarticle
usepackageamsmath, amssymb
usepackagearray

usepackagexinttools
usepackagebnumexpr
begindocument

This is a Cayley table
[
beginarray*5l
& 1 & a & a^2 & a^3 & a^4 \
hline
1 & 1 & a & a^2 & a^3 & a^4 \
a & a & a^2 & a^3 & a^4 & a^5 \
a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
endarray
]

This is the same, but with some more spacing,
[
setlengthextrarowheight3pt% local setting
beginarray*5l
& 1 & a & a^2 & a^3 & a^4 \
hline
1 & 1 & a & a^2 & a^3 & a^4 \
a & a & a^2 & a^3 & a^4 & a^5 \
a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
endarray
]

Again, but illustrating that $a=4$ generates a cyclic sub-group of order
$5$ of $(mathbbZ/11mathbbZ)^*$:
[
setlengthextrarowheight3pt% local setting
beginarrayc
& 1 & a & a^2 & a^3 & a^4 \
hline
xintFor #1 in 0, 1, 2, 3, 4:
ifnum #1=0 1else a^#1fi
xintFor #2 in 0, 1, 2, 3, 4:
%
&thebnumexpr 4^(#1+#2) /: 11relax
%
\
%
endarray
]
and $a=2$ generates the full group:
[
setlengthextrarowheight3pt% local setting
beginarray*10c
& 1 & a xintFor*#1 in 23456789:&a^#1\
hline
xintFor* #1 in 0123456789:
ifnum #1=0 1else a^#1fi
xintFor* #2 in 0123456789:
%
&thebnumexpr 2^(#1+#2) /: 11relax
%
\
%
endarray
]
enddocument


enter image description here






share|improve this answer























  • +1 I'm always amazed at how efficient xinttools is!

    – Andrew
    Nov 13 '18 at 7:06











  • @Andrew your expl3 answer does look efficient too :)

    – jfbu
    Nov 13 '18 at 8:05


















5














Perhaps I over automate, but I'd want to have a macro CayleyTable that produces the Cayley table of the corresponding cyclic group, so that the commands:



 CayleyTable3
CayleyTable4
CayleyTable[x]9


would produce:



enter image description here



(An optional argument gives the name of the generator, which defaults to a). Arguably, CyclicGroupCayleyTable would be a better name. In any case,
here's the code:



documentclassarticle
usepackagearray
setlengthextrarowheight3pt% local setting

usepackagexparse

ExplSyntaxOn
int_new:N l_n_int
tl_new:N l_gen_tl
cs_new_protected:Npn print_exponent #1 % l_gen_tl^#1
int_compare:nTF #1=01l_gen_tl int_compare:nT#1>1^#1

cs_new_protected:Npn print_Cayley_header:n #1
& print_exponent int_eval:n#1-1

cs_new_protected:Npn print_Cayley_cell:nn #1 #2
& print_exponent int_eval:n int_mod:nn #1+#2-2l_n_int

cs_new_protected:Npn print_Cayley_row:n #1
print_exponent int_eval:n #1-1
int_step_inline:nn l_n_int print_Cayley_cell:nn ##1#1 \

NewDocumentCommandCayleyTable Oa m
tl_set:Nn l_gen_tl #1
int_set:Nn l_n_int #2
[
beginarray*int_eval:nl_n_int+1c
int_step_function:nN l_n_int print_Cayley_header:n
\hline
int_step_function:nN l_n_int print_Cayley_row:n
endarray
]

ExplSyntaxOff

begindocument

CayleyTable3

CayleyTable4

CayleyTable[x]9

enddocument





share|improve this answer
































    0














    With foreach:



    documentclassarticle
    usepackageetoolbox
    usepackagetikz
    tikzsetmynode/.style=anchor=base,
    inner sep=0pt,
    text height=12pt, text depth=6pt, text width=18pt, text centered
    newcommandCayleyTable[2][a]%
    vcenterhboxbegintikzpicture
    pgfmathsetmacrototint(#2-1)
    foreach i in 0,1,...,tot

    node[mynode] (hh-i) at (i *24pt,24pt) ifnumequali0$1$ifnumequali1$#1$$#1^i$;
    node[mynode] (vv-i) at (-24pt-pgflinewidth,-i *24pt) ifnumequali0$1$ifnumequali1$#1$$#1^i$;

    foreach myrow in 0,1,...,tot
    foreach mycol in 0,1,...,tot
    pgfmathsetmacromyplusmyrow+mycolpgfmathsetmacromyexpint(mod(myplus,#2))
    node[mynode] at (myrow*24pt,-mycol*24pt) ifnumequalmyexp0$1$ifnumequalmyexp1$#1$$#1^myexp$;
    draw ([yshift=-2pt]hh-tot.south east) -- ([yshift=-2pt]hh-0.south west) -- ++(-24pt, 0);
    draw ([xshift=2pt]vv-tot.south east) -- ([xshift=2pt]vv-0.north east) -- ++(0,24pt);
    endtikzpicture%

    begindocument
    [
    CayleyTable3
    ]
    [
    CayleyTable[x]4
    ]
    [
    CayleyTable[y]5
    ]
    enddocument


    enter image description here






    share|improve this answer






















      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "85"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f459639%2fhow-to-draw-a-cayley-table%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      5 Answers
      5






      active

      oldest

      votes








      5 Answers
      5






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      9














      Basically I've just taken the answer to the question you linked and changed few lines to adapt to your needs.



      Here's the code, followed by the output you will get and a brief explanation of what's going on.



      The code below produces 2 tables, in one there's written ANYTHING in the top left corner, in the second one there's a white space (just don't put anything in the column "argument".



      documentclass[10pt]article
      usepackagearray

      begindocument

      setlengthextrarowheight3pt
      noindentbegintabular c c c c c
      ANYTHING & 0 & 1 & 2 & 3 & 4 \
      cline1-6
      0 & 0 & 0 & 0 & 0 & 0 \
      1 & 0 & 0 & $a^2$ & 25 & 25 \
      2 & $a^2$ & 0 & 20 & 25 & 25 \
      2 & 0 & $a^2$ & 20 & 25 & 25 \
      2 & 0 & 0 & 20 & 25 & 25 \
      endtabular


      noindentbegintabular c c c c c
      & 0 & 1 & 2 & 3 & 4 \
      cline1-6
      0 & 0 & 0 & 0 & 0 & 0 \
      1 & 0 & 0 & $a^2$ & 25 & 25 \
      2 & $a^2$ & 0 & 20 & 25 & 25 \
      2 & 0 & $a^2$ & 20 & 25 & 25 \
      2 & 0 & 0 & 20 & 25 & 25 \
      endtabular

      enddocument


      enter image description hereenter image description here



      How does it work? A table is done with the environment tabular, which requires as argument the numer of columns (or rows... just read the documentation to know more) which is specified by the argument c c c c c: 6 columns divided by a line between the first and the second col. The 'c' stands for centered meaning that the column will be aligned to the center, if you want you can change it to l (left) or r (right).



      Then in the tables all the entries are done by spacing them with &, and the cline takes as argument the number of columns that you want it to span: from column 1 to column 6.



      The command setlengthextrarowheight3pt adds some extra row height (how surprising!).



      Package array is needed for the length extrarowheight.






      share|improve this answer




















      • 1





        this is good however I wanted a 5x5 table

        – A.E
        Nov 12 '18 at 16:00






      • 1





        Cheers pal, much appreciated.

        – A.E
        Nov 12 '18 at 16:02






      • 1





        if you could briefly explain what you did line by line, It would be more beneficial so I know what you've done

        – A.E
        Nov 12 '18 at 16:03






      • 1





        much appreciated

        – A.E
        Nov 12 '18 at 16:11











      • I added more on the meaning of the c's in tabular environment.

        – GiuTeX
        Nov 12 '18 at 16:12















      9














      Basically I've just taken the answer to the question you linked and changed few lines to adapt to your needs.



      Here's the code, followed by the output you will get and a brief explanation of what's going on.



      The code below produces 2 tables, in one there's written ANYTHING in the top left corner, in the second one there's a white space (just don't put anything in the column "argument".



      documentclass[10pt]article
      usepackagearray

      begindocument

      setlengthextrarowheight3pt
      noindentbegintabular c c c c c
      ANYTHING & 0 & 1 & 2 & 3 & 4 \
      cline1-6
      0 & 0 & 0 & 0 & 0 & 0 \
      1 & 0 & 0 & $a^2$ & 25 & 25 \
      2 & $a^2$ & 0 & 20 & 25 & 25 \
      2 & 0 & $a^2$ & 20 & 25 & 25 \
      2 & 0 & 0 & 20 & 25 & 25 \
      endtabular


      noindentbegintabular c c c c c
      & 0 & 1 & 2 & 3 & 4 \
      cline1-6
      0 & 0 & 0 & 0 & 0 & 0 \
      1 & 0 & 0 & $a^2$ & 25 & 25 \
      2 & $a^2$ & 0 & 20 & 25 & 25 \
      2 & 0 & $a^2$ & 20 & 25 & 25 \
      2 & 0 & 0 & 20 & 25 & 25 \
      endtabular

      enddocument


      enter image description hereenter image description here



      How does it work? A table is done with the environment tabular, which requires as argument the numer of columns (or rows... just read the documentation to know more) which is specified by the argument c c c c c: 6 columns divided by a line between the first and the second col. The 'c' stands for centered meaning that the column will be aligned to the center, if you want you can change it to l (left) or r (right).



      Then in the tables all the entries are done by spacing them with &, and the cline takes as argument the number of columns that you want it to span: from column 1 to column 6.



      The command setlengthextrarowheight3pt adds some extra row height (how surprising!).



      Package array is needed for the length extrarowheight.






      share|improve this answer




















      • 1





        this is good however I wanted a 5x5 table

        – A.E
        Nov 12 '18 at 16:00






      • 1





        Cheers pal, much appreciated.

        – A.E
        Nov 12 '18 at 16:02






      • 1





        if you could briefly explain what you did line by line, It would be more beneficial so I know what you've done

        – A.E
        Nov 12 '18 at 16:03






      • 1





        much appreciated

        – A.E
        Nov 12 '18 at 16:11











      • I added more on the meaning of the c's in tabular environment.

        – GiuTeX
        Nov 12 '18 at 16:12













      9












      9








      9







      Basically I've just taken the answer to the question you linked and changed few lines to adapt to your needs.



      Here's the code, followed by the output you will get and a brief explanation of what's going on.



      The code below produces 2 tables, in one there's written ANYTHING in the top left corner, in the second one there's a white space (just don't put anything in the column "argument".



      documentclass[10pt]article
      usepackagearray

      begindocument

      setlengthextrarowheight3pt
      noindentbegintabular c c c c c
      ANYTHING & 0 & 1 & 2 & 3 & 4 \
      cline1-6
      0 & 0 & 0 & 0 & 0 & 0 \
      1 & 0 & 0 & $a^2$ & 25 & 25 \
      2 & $a^2$ & 0 & 20 & 25 & 25 \
      2 & 0 & $a^2$ & 20 & 25 & 25 \
      2 & 0 & 0 & 20 & 25 & 25 \
      endtabular


      noindentbegintabular c c c c c
      & 0 & 1 & 2 & 3 & 4 \
      cline1-6
      0 & 0 & 0 & 0 & 0 & 0 \
      1 & 0 & 0 & $a^2$ & 25 & 25 \
      2 & $a^2$ & 0 & 20 & 25 & 25 \
      2 & 0 & $a^2$ & 20 & 25 & 25 \
      2 & 0 & 0 & 20 & 25 & 25 \
      endtabular

      enddocument


      enter image description hereenter image description here



      How does it work? A table is done with the environment tabular, which requires as argument the numer of columns (or rows... just read the documentation to know more) which is specified by the argument c c c c c: 6 columns divided by a line between the first and the second col. The 'c' stands for centered meaning that the column will be aligned to the center, if you want you can change it to l (left) or r (right).



      Then in the tables all the entries are done by spacing them with &, and the cline takes as argument the number of columns that you want it to span: from column 1 to column 6.



      The command setlengthextrarowheight3pt adds some extra row height (how surprising!).



      Package array is needed for the length extrarowheight.






      share|improve this answer















      Basically I've just taken the answer to the question you linked and changed few lines to adapt to your needs.



      Here's the code, followed by the output you will get and a brief explanation of what's going on.



      The code below produces 2 tables, in one there's written ANYTHING in the top left corner, in the second one there's a white space (just don't put anything in the column "argument".



      documentclass[10pt]article
      usepackagearray

      begindocument

      setlengthextrarowheight3pt
      noindentbegintabular c c c c c
      ANYTHING & 0 & 1 & 2 & 3 & 4 \
      cline1-6
      0 & 0 & 0 & 0 & 0 & 0 \
      1 & 0 & 0 & $a^2$ & 25 & 25 \
      2 & $a^2$ & 0 & 20 & 25 & 25 \
      2 & 0 & $a^2$ & 20 & 25 & 25 \
      2 & 0 & 0 & 20 & 25 & 25 \
      endtabular


      noindentbegintabular c c c c c
      & 0 & 1 & 2 & 3 & 4 \
      cline1-6
      0 & 0 & 0 & 0 & 0 & 0 \
      1 & 0 & 0 & $a^2$ & 25 & 25 \
      2 & $a^2$ & 0 & 20 & 25 & 25 \
      2 & 0 & $a^2$ & 20 & 25 & 25 \
      2 & 0 & 0 & 20 & 25 & 25 \
      endtabular

      enddocument


      enter image description hereenter image description here



      How does it work? A table is done with the environment tabular, which requires as argument the numer of columns (or rows... just read the documentation to know more) which is specified by the argument c c c c c: 6 columns divided by a line between the first and the second col. The 'c' stands for centered meaning that the column will be aligned to the center, if you want you can change it to l (left) or r (right).



      Then in the tables all the entries are done by spacing them with &, and the cline takes as argument the number of columns that you want it to span: from column 1 to column 6.



      The command setlengthextrarowheight3pt adds some extra row height (how surprising!).



      Package array is needed for the length extrarowheight.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Nov 12 '18 at 16:22

























      answered Nov 12 '18 at 15:58









      GiuTeXGiuTeX

      666317




      666317







      • 1





        this is good however I wanted a 5x5 table

        – A.E
        Nov 12 '18 at 16:00






      • 1





        Cheers pal, much appreciated.

        – A.E
        Nov 12 '18 at 16:02






      • 1





        if you could briefly explain what you did line by line, It would be more beneficial so I know what you've done

        – A.E
        Nov 12 '18 at 16:03






      • 1





        much appreciated

        – A.E
        Nov 12 '18 at 16:11











      • I added more on the meaning of the c's in tabular environment.

        – GiuTeX
        Nov 12 '18 at 16:12












      • 1





        this is good however I wanted a 5x5 table

        – A.E
        Nov 12 '18 at 16:00






      • 1





        Cheers pal, much appreciated.

        – A.E
        Nov 12 '18 at 16:02






      • 1





        if you could briefly explain what you did line by line, It would be more beneficial so I know what you've done

        – A.E
        Nov 12 '18 at 16:03






      • 1





        much appreciated

        – A.E
        Nov 12 '18 at 16:11











      • I added more on the meaning of the c's in tabular environment.

        – GiuTeX
        Nov 12 '18 at 16:12







      1




      1





      this is good however I wanted a 5x5 table

      – A.E
      Nov 12 '18 at 16:00





      this is good however I wanted a 5x5 table

      – A.E
      Nov 12 '18 at 16:00




      1




      1





      Cheers pal, much appreciated.

      – A.E
      Nov 12 '18 at 16:02





      Cheers pal, much appreciated.

      – A.E
      Nov 12 '18 at 16:02




      1




      1





      if you could briefly explain what you did line by line, It would be more beneficial so I know what you've done

      – A.E
      Nov 12 '18 at 16:03





      if you could briefly explain what you did line by line, It would be more beneficial so I know what you've done

      – A.E
      Nov 12 '18 at 16:03




      1




      1





      much appreciated

      – A.E
      Nov 12 '18 at 16:11





      much appreciated

      – A.E
      Nov 12 '18 at 16:11













      I added more on the meaning of the c's in tabular environment.

      – GiuTeX
      Nov 12 '18 at 16:12





      I added more on the meaning of the c's in tabular environment.

      – GiuTeX
      Nov 12 '18 at 16:12











      12














      Your input is almost good, but you can do better.



      documentclassarticle
      usepackageamsmath
      usepackagearray

      begindocument

      This is a Cayley table
      [
      beginarray*5l
      & 1 & a & a^2 & a^3 & a^4 \
      hline
      1 & 1 & a & a^2 & a^3 & a^4 \
      a & a & a^2 & a^3 & a^4 & a^5 \
      a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
      a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
      a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
      endarray
      ]

      This is the same, but with some more spacing,
      [
      setlengthextrarowheight3pt% local setting
      beginarray*5l
      & 1 & a & a^2 & a^3 & a^4 \
      hline
      1 & 1 & a & a^2 & a^3 & a^4 \
      a & a & a^2 & a^3 & a^4 & a^5 \
      a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
      a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
      a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
      endarray
      ]

      enddocument


      With array, each cell is assumed to be in math mode. The setting of extrarowheight will not propagate to other instances of array, because [...] forms a group.



      enter image description here






      share|improve this answer




















      • 1





        I prefer the method above as it is easier to follow(in my eyes anyway) but thanks for your answer

        – A.E
        Nov 12 '18 at 16:16







      • 1





        What does * in l|* mean?

        – manooooh
        Nov 12 '18 at 16:17






      • 2





        @manooooh *6l is short for llllll

        – samcarter
        Nov 12 '18 at 16:18






      • 3





        @manooooh The * refers to the following: *6l means “repeat l six times”.

        – egreg
        Nov 12 '18 at 16:18











      • @jfbu Right, fixed

        – egreg
        Nov 12 '18 at 16:47















      12














      Your input is almost good, but you can do better.



      documentclassarticle
      usepackageamsmath
      usepackagearray

      begindocument

      This is a Cayley table
      [
      beginarray*5l
      & 1 & a & a^2 & a^3 & a^4 \
      hline
      1 & 1 & a & a^2 & a^3 & a^4 \
      a & a & a^2 & a^3 & a^4 & a^5 \
      a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
      a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
      a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
      endarray
      ]

      This is the same, but with some more spacing,
      [
      setlengthextrarowheight3pt% local setting
      beginarray*5l
      & 1 & a & a^2 & a^3 & a^4 \
      hline
      1 & 1 & a & a^2 & a^3 & a^4 \
      a & a & a^2 & a^3 & a^4 & a^5 \
      a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
      a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
      a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
      endarray
      ]

      enddocument


      With array, each cell is assumed to be in math mode. The setting of extrarowheight will not propagate to other instances of array, because [...] forms a group.



      enter image description here






      share|improve this answer




















      • 1





        I prefer the method above as it is easier to follow(in my eyes anyway) but thanks for your answer

        – A.E
        Nov 12 '18 at 16:16







      • 1





        What does * in l|* mean?

        – manooooh
        Nov 12 '18 at 16:17






      • 2





        @manooooh *6l is short for llllll

        – samcarter
        Nov 12 '18 at 16:18






      • 3





        @manooooh The * refers to the following: *6l means “repeat l six times”.

        – egreg
        Nov 12 '18 at 16:18











      • @jfbu Right, fixed

        – egreg
        Nov 12 '18 at 16:47













      12












      12








      12







      Your input is almost good, but you can do better.



      documentclassarticle
      usepackageamsmath
      usepackagearray

      begindocument

      This is a Cayley table
      [
      beginarray*5l
      & 1 & a & a^2 & a^3 & a^4 \
      hline
      1 & 1 & a & a^2 & a^3 & a^4 \
      a & a & a^2 & a^3 & a^4 & a^5 \
      a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
      a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
      a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
      endarray
      ]

      This is the same, but with some more spacing,
      [
      setlengthextrarowheight3pt% local setting
      beginarray*5l
      & 1 & a & a^2 & a^3 & a^4 \
      hline
      1 & 1 & a & a^2 & a^3 & a^4 \
      a & a & a^2 & a^3 & a^4 & a^5 \
      a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
      a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
      a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
      endarray
      ]

      enddocument


      With array, each cell is assumed to be in math mode. The setting of extrarowheight will not propagate to other instances of array, because [...] forms a group.



      enter image description here






      share|improve this answer















      Your input is almost good, but you can do better.



      documentclassarticle
      usepackageamsmath
      usepackagearray

      begindocument

      This is a Cayley table
      [
      beginarray*5l
      & 1 & a & a^2 & a^3 & a^4 \
      hline
      1 & 1 & a & a^2 & a^3 & a^4 \
      a & a & a^2 & a^3 & a^4 & a^5 \
      a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
      a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
      a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
      endarray
      ]

      This is the same, but with some more spacing,
      [
      setlengthextrarowheight3pt% local setting
      beginarray*5l
      & 1 & a & a^2 & a^3 & a^4 \
      hline
      1 & 1 & a & a^2 & a^3 & a^4 \
      a & a & a^2 & a^3 & a^4 & a^5 \
      a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
      a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
      a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
      endarray
      ]

      enddocument


      With array, each cell is assumed to be in math mode. The setting of extrarowheight will not propagate to other instances of array, because [...] forms a group.



      enter image description here







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Nov 12 '18 at 16:47

























      answered Nov 12 '18 at 16:14









      egregegreg

      714k8618983184




      714k8618983184







      • 1





        I prefer the method above as it is easier to follow(in my eyes anyway) but thanks for your answer

        – A.E
        Nov 12 '18 at 16:16







      • 1





        What does * in l|* mean?

        – manooooh
        Nov 12 '18 at 16:17






      • 2





        @manooooh *6l is short for llllll

        – samcarter
        Nov 12 '18 at 16:18






      • 3





        @manooooh The * refers to the following: *6l means “repeat l six times”.

        – egreg
        Nov 12 '18 at 16:18











      • @jfbu Right, fixed

        – egreg
        Nov 12 '18 at 16:47












      • 1





        I prefer the method above as it is easier to follow(in my eyes anyway) but thanks for your answer

        – A.E
        Nov 12 '18 at 16:16







      • 1





        What does * in l|* mean?

        – manooooh
        Nov 12 '18 at 16:17






      • 2





        @manooooh *6l is short for llllll

        – samcarter
        Nov 12 '18 at 16:18






      • 3





        @manooooh The * refers to the following: *6l means “repeat l six times”.

        – egreg
        Nov 12 '18 at 16:18











      • @jfbu Right, fixed

        – egreg
        Nov 12 '18 at 16:47







      1




      1





      I prefer the method above as it is easier to follow(in my eyes anyway) but thanks for your answer

      – A.E
      Nov 12 '18 at 16:16






      I prefer the method above as it is easier to follow(in my eyes anyway) but thanks for your answer

      – A.E
      Nov 12 '18 at 16:16





      1




      1





      What does * in l|* mean?

      – manooooh
      Nov 12 '18 at 16:17





      What does * in l|* mean?

      – manooooh
      Nov 12 '18 at 16:17




      2




      2





      @manooooh *6l is short for llllll

      – samcarter
      Nov 12 '18 at 16:18





      @manooooh *6l is short for llllll

      – samcarter
      Nov 12 '18 at 16:18




      3




      3





      @manooooh The * refers to the following: *6l means “repeat l six times”.

      – egreg
      Nov 12 '18 at 16:18





      @manooooh The * refers to the following: *6l means “repeat l six times”.

      – egreg
      Nov 12 '18 at 16:18













      @jfbu Right, fixed

      – egreg
      Nov 12 '18 at 16:47





      @jfbu Right, fixed

      – egreg
      Nov 12 '18 at 16:47











      10














      Some automatizing is in order here



      documentclassarticle
      usepackageamsmath, amssymb
      usepackagearray

      usepackagexinttools
      usepackagebnumexpr
      begindocument

      This is a Cayley table
      [
      beginarray*5l
      & 1 & a & a^2 & a^3 & a^4 \
      hline
      1 & 1 & a & a^2 & a^3 & a^4 \
      a & a & a^2 & a^3 & a^4 & a^5 \
      a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
      a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
      a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
      endarray
      ]

      This is the same, but with some more spacing,
      [
      setlengthextrarowheight3pt% local setting
      beginarray*5l
      & 1 & a & a^2 & a^3 & a^4 \
      hline
      1 & 1 & a & a^2 & a^3 & a^4 \
      a & a & a^2 & a^3 & a^4 & a^5 \
      a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
      a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
      a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
      endarray
      ]

      Again, but illustrating that $a=4$ generates a cyclic sub-group of order
      $5$ of $(mathbbZ/11mathbbZ)^*$:
      [
      setlengthextrarowheight3pt% local setting
      beginarrayc
      & 1 & a & a^2 & a^3 & a^4 \
      hline
      xintFor #1 in 0, 1, 2, 3, 4:
      ifnum #1=0 1else a^#1fi
      xintFor #2 in 0, 1, 2, 3, 4:
      %
      &thebnumexpr 4^(#1+#2) /: 11relax
      %
      \
      %
      endarray
      ]
      and $a=2$ generates the full group:
      [
      setlengthextrarowheight3pt% local setting
      beginarray*10c
      & 1 & a xintFor*#1 in 23456789:&a^#1\
      hline
      xintFor* #1 in 0123456789:
      ifnum #1=0 1else a^#1fi
      xintFor* #2 in 0123456789:
      %
      &thebnumexpr 2^(#1+#2) /: 11relax
      %
      \
      %
      endarray
      ]
      enddocument


      enter image description here






      share|improve this answer























      • +1 I'm always amazed at how efficient xinttools is!

        – Andrew
        Nov 13 '18 at 7:06











      • @Andrew your expl3 answer does look efficient too :)

        – jfbu
        Nov 13 '18 at 8:05















      10














      Some automatizing is in order here



      documentclassarticle
      usepackageamsmath, amssymb
      usepackagearray

      usepackagexinttools
      usepackagebnumexpr
      begindocument

      This is a Cayley table
      [
      beginarray*5l
      & 1 & a & a^2 & a^3 & a^4 \
      hline
      1 & 1 & a & a^2 & a^3 & a^4 \
      a & a & a^2 & a^3 & a^4 & a^5 \
      a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
      a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
      a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
      endarray
      ]

      This is the same, but with some more spacing,
      [
      setlengthextrarowheight3pt% local setting
      beginarray*5l
      & 1 & a & a^2 & a^3 & a^4 \
      hline
      1 & 1 & a & a^2 & a^3 & a^4 \
      a & a & a^2 & a^3 & a^4 & a^5 \
      a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
      a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
      a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
      endarray
      ]

      Again, but illustrating that $a=4$ generates a cyclic sub-group of order
      $5$ of $(mathbbZ/11mathbbZ)^*$:
      [
      setlengthextrarowheight3pt% local setting
      beginarrayc
      & 1 & a & a^2 & a^3 & a^4 \
      hline
      xintFor #1 in 0, 1, 2, 3, 4:
      ifnum #1=0 1else a^#1fi
      xintFor #2 in 0, 1, 2, 3, 4:
      %
      &thebnumexpr 4^(#1+#2) /: 11relax
      %
      \
      %
      endarray
      ]
      and $a=2$ generates the full group:
      [
      setlengthextrarowheight3pt% local setting
      beginarray*10c
      & 1 & a xintFor*#1 in 23456789:&a^#1\
      hline
      xintFor* #1 in 0123456789:
      ifnum #1=0 1else a^#1fi
      xintFor* #2 in 0123456789:
      %
      &thebnumexpr 2^(#1+#2) /: 11relax
      %
      \
      %
      endarray
      ]
      enddocument


      enter image description here






      share|improve this answer























      • +1 I'm always amazed at how efficient xinttools is!

        – Andrew
        Nov 13 '18 at 7:06











      • @Andrew your expl3 answer does look efficient too :)

        – jfbu
        Nov 13 '18 at 8:05













      10












      10








      10







      Some automatizing is in order here



      documentclassarticle
      usepackageamsmath, amssymb
      usepackagearray

      usepackagexinttools
      usepackagebnumexpr
      begindocument

      This is a Cayley table
      [
      beginarray*5l
      & 1 & a & a^2 & a^3 & a^4 \
      hline
      1 & 1 & a & a^2 & a^3 & a^4 \
      a & a & a^2 & a^3 & a^4 & a^5 \
      a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
      a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
      a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
      endarray
      ]

      This is the same, but with some more spacing,
      [
      setlengthextrarowheight3pt% local setting
      beginarray*5l
      & 1 & a & a^2 & a^3 & a^4 \
      hline
      1 & 1 & a & a^2 & a^3 & a^4 \
      a & a & a^2 & a^3 & a^4 & a^5 \
      a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
      a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
      a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
      endarray
      ]

      Again, but illustrating that $a=4$ generates a cyclic sub-group of order
      $5$ of $(mathbbZ/11mathbbZ)^*$:
      [
      setlengthextrarowheight3pt% local setting
      beginarrayc
      & 1 & a & a^2 & a^3 & a^4 \
      hline
      xintFor #1 in 0, 1, 2, 3, 4:
      ifnum #1=0 1else a^#1fi
      xintFor #2 in 0, 1, 2, 3, 4:
      %
      &thebnumexpr 4^(#1+#2) /: 11relax
      %
      \
      %
      endarray
      ]
      and $a=2$ generates the full group:
      [
      setlengthextrarowheight3pt% local setting
      beginarray*10c
      & 1 & a xintFor*#1 in 23456789:&a^#1\
      hline
      xintFor* #1 in 0123456789:
      ifnum #1=0 1else a^#1fi
      xintFor* #2 in 0123456789:
      %
      &thebnumexpr 2^(#1+#2) /: 11relax
      %
      \
      %
      endarray
      ]
      enddocument


      enter image description here






      share|improve this answer













      Some automatizing is in order here



      documentclassarticle
      usepackageamsmath, amssymb
      usepackagearray

      usepackagexinttools
      usepackagebnumexpr
      begindocument

      This is a Cayley table
      [
      beginarray*5l
      & 1 & a & a^2 & a^3 & a^4 \
      hline
      1 & 1 & a & a^2 & a^3 & a^4 \
      a & a & a^2 & a^3 & a^4 & a^5 \
      a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
      a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
      a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
      endarray
      ]

      This is the same, but with some more spacing,
      [
      setlengthextrarowheight3pt% local setting
      beginarray*5l
      & 1 & a & a^2 & a^3 & a^4 \
      hline
      1 & 1 & a & a^2 & a^3 & a^4 \
      a & a & a^2 & a^3 & a^4 & a^5 \
      a^2 & a^2 & a^3 & a^4 & a^5 & a^6 \
      a^3 & a^3 & a^4 & a^5 & a^6 & a^7 \
      a^4 & a^4 & a^5 & a^6 & a^7 & a^8 \
      endarray
      ]

      Again, but illustrating that $a=4$ generates a cyclic sub-group of order
      $5$ of $(mathbbZ/11mathbbZ)^*$:
      [
      setlengthextrarowheight3pt% local setting
      beginarrayc
      & 1 & a & a^2 & a^3 & a^4 \
      hline
      xintFor #1 in 0, 1, 2, 3, 4:
      ifnum #1=0 1else a^#1fi
      xintFor #2 in 0, 1, 2, 3, 4:
      %
      &thebnumexpr 4^(#1+#2) /: 11relax
      %
      \
      %
      endarray
      ]
      and $a=2$ generates the full group:
      [
      setlengthextrarowheight3pt% local setting
      beginarray*10c
      & 1 & a xintFor*#1 in 23456789:&a^#1\
      hline
      xintFor* #1 in 0123456789:
      ifnum #1=0 1else a^#1fi
      xintFor* #2 in 0123456789:
      %
      &thebnumexpr 2^(#1+#2) /: 11relax
      %
      \
      %
      endarray
      ]
      enddocument


      enter image description here







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Nov 12 '18 at 16:45









      jfbujfbu

      47k66149




      47k66149












      • +1 I'm always amazed at how efficient xinttools is!

        – Andrew
        Nov 13 '18 at 7:06











      • @Andrew your expl3 answer does look efficient too :)

        – jfbu
        Nov 13 '18 at 8:05

















      • +1 I'm always amazed at how efficient xinttools is!

        – Andrew
        Nov 13 '18 at 7:06











      • @Andrew your expl3 answer does look efficient too :)

        – jfbu
        Nov 13 '18 at 8:05
















      +1 I'm always amazed at how efficient xinttools is!

      – Andrew
      Nov 13 '18 at 7:06





      +1 I'm always amazed at how efficient xinttools is!

      – Andrew
      Nov 13 '18 at 7:06













      @Andrew your expl3 answer does look efficient too :)

      – jfbu
      Nov 13 '18 at 8:05





      @Andrew your expl3 answer does look efficient too :)

      – jfbu
      Nov 13 '18 at 8:05











      5














      Perhaps I over automate, but I'd want to have a macro CayleyTable that produces the Cayley table of the corresponding cyclic group, so that the commands:



       CayleyTable3
      CayleyTable4
      CayleyTable[x]9


      would produce:



      enter image description here



      (An optional argument gives the name of the generator, which defaults to a). Arguably, CyclicGroupCayleyTable would be a better name. In any case,
      here's the code:



      documentclassarticle
      usepackagearray
      setlengthextrarowheight3pt% local setting

      usepackagexparse

      ExplSyntaxOn
      int_new:N l_n_int
      tl_new:N l_gen_tl
      cs_new_protected:Npn print_exponent #1 % l_gen_tl^#1
      int_compare:nTF #1=01l_gen_tl int_compare:nT#1>1^#1

      cs_new_protected:Npn print_Cayley_header:n #1
      & print_exponent int_eval:n#1-1

      cs_new_protected:Npn print_Cayley_cell:nn #1 #2
      & print_exponent int_eval:n int_mod:nn #1+#2-2l_n_int

      cs_new_protected:Npn print_Cayley_row:n #1
      print_exponent int_eval:n #1-1
      int_step_inline:nn l_n_int print_Cayley_cell:nn ##1#1 \

      NewDocumentCommandCayleyTable Oa m
      tl_set:Nn l_gen_tl #1
      int_set:Nn l_n_int #2
      [
      beginarray*int_eval:nl_n_int+1c
      int_step_function:nN l_n_int print_Cayley_header:n
      \hline
      int_step_function:nN l_n_int print_Cayley_row:n
      endarray
      ]

      ExplSyntaxOff

      begindocument

      CayleyTable3

      CayleyTable4

      CayleyTable[x]9

      enddocument





      share|improve this answer





























        5














        Perhaps I over automate, but I'd want to have a macro CayleyTable that produces the Cayley table of the corresponding cyclic group, so that the commands:



         CayleyTable3
        CayleyTable4
        CayleyTable[x]9


        would produce:



        enter image description here



        (An optional argument gives the name of the generator, which defaults to a). Arguably, CyclicGroupCayleyTable would be a better name. In any case,
        here's the code:



        documentclassarticle
        usepackagearray
        setlengthextrarowheight3pt% local setting

        usepackagexparse

        ExplSyntaxOn
        int_new:N l_n_int
        tl_new:N l_gen_tl
        cs_new_protected:Npn print_exponent #1 % l_gen_tl^#1
        int_compare:nTF #1=01l_gen_tl int_compare:nT#1>1^#1

        cs_new_protected:Npn print_Cayley_header:n #1
        & print_exponent int_eval:n#1-1

        cs_new_protected:Npn print_Cayley_cell:nn #1 #2
        & print_exponent int_eval:n int_mod:nn #1+#2-2l_n_int

        cs_new_protected:Npn print_Cayley_row:n #1
        print_exponent int_eval:n #1-1
        int_step_inline:nn l_n_int print_Cayley_cell:nn ##1#1 \

        NewDocumentCommandCayleyTable Oa m
        tl_set:Nn l_gen_tl #1
        int_set:Nn l_n_int #2
        [
        beginarray*int_eval:nl_n_int+1c
        int_step_function:nN l_n_int print_Cayley_header:n
        \hline
        int_step_function:nN l_n_int print_Cayley_row:n
        endarray
        ]

        ExplSyntaxOff

        begindocument

        CayleyTable3

        CayleyTable4

        CayleyTable[x]9

        enddocument





        share|improve this answer



























          5












          5








          5







          Perhaps I over automate, but I'd want to have a macro CayleyTable that produces the Cayley table of the corresponding cyclic group, so that the commands:



           CayleyTable3
          CayleyTable4
          CayleyTable[x]9


          would produce:



          enter image description here



          (An optional argument gives the name of the generator, which defaults to a). Arguably, CyclicGroupCayleyTable would be a better name. In any case,
          here's the code:



          documentclassarticle
          usepackagearray
          setlengthextrarowheight3pt% local setting

          usepackagexparse

          ExplSyntaxOn
          int_new:N l_n_int
          tl_new:N l_gen_tl
          cs_new_protected:Npn print_exponent #1 % l_gen_tl^#1
          int_compare:nTF #1=01l_gen_tl int_compare:nT#1>1^#1

          cs_new_protected:Npn print_Cayley_header:n #1
          & print_exponent int_eval:n#1-1

          cs_new_protected:Npn print_Cayley_cell:nn #1 #2
          & print_exponent int_eval:n int_mod:nn #1+#2-2l_n_int

          cs_new_protected:Npn print_Cayley_row:n #1
          print_exponent int_eval:n #1-1
          int_step_inline:nn l_n_int print_Cayley_cell:nn ##1#1 \

          NewDocumentCommandCayleyTable Oa m
          tl_set:Nn l_gen_tl #1
          int_set:Nn l_n_int #2
          [
          beginarray*int_eval:nl_n_int+1c
          int_step_function:nN l_n_int print_Cayley_header:n
          \hline
          int_step_function:nN l_n_int print_Cayley_row:n
          endarray
          ]

          ExplSyntaxOff

          begindocument

          CayleyTable3

          CayleyTable4

          CayleyTable[x]9

          enddocument





          share|improve this answer















          Perhaps I over automate, but I'd want to have a macro CayleyTable that produces the Cayley table of the corresponding cyclic group, so that the commands:



           CayleyTable3
          CayleyTable4
          CayleyTable[x]9


          would produce:



          enter image description here



          (An optional argument gives the name of the generator, which defaults to a). Arguably, CyclicGroupCayleyTable would be a better name. In any case,
          here's the code:



          documentclassarticle
          usepackagearray
          setlengthextrarowheight3pt% local setting

          usepackagexparse

          ExplSyntaxOn
          int_new:N l_n_int
          tl_new:N l_gen_tl
          cs_new_protected:Npn print_exponent #1 % l_gen_tl^#1
          int_compare:nTF #1=01l_gen_tl int_compare:nT#1>1^#1

          cs_new_protected:Npn print_Cayley_header:n #1
          & print_exponent int_eval:n#1-1

          cs_new_protected:Npn print_Cayley_cell:nn #1 #2
          & print_exponent int_eval:n int_mod:nn #1+#2-2l_n_int

          cs_new_protected:Npn print_Cayley_row:n #1
          print_exponent int_eval:n #1-1
          int_step_inline:nn l_n_int print_Cayley_cell:nn ##1#1 \

          NewDocumentCommandCayleyTable Oa m
          tl_set:Nn l_gen_tl #1
          int_set:Nn l_n_int #2
          [
          beginarray*int_eval:nl_n_int+1c
          int_step_function:nN l_n_int print_Cayley_header:n
          \hline
          int_step_function:nN l_n_int print_Cayley_row:n
          endarray
          ]

          ExplSyntaxOff

          begindocument

          CayleyTable3

          CayleyTable4

          CayleyTable[x]9

          enddocument






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 13 '18 at 19:31

























          answered Nov 13 '18 at 5:44









          AndrewAndrew

          30.5k34381




          30.5k34381





















              0














              With foreach:



              documentclassarticle
              usepackageetoolbox
              usepackagetikz
              tikzsetmynode/.style=anchor=base,
              inner sep=0pt,
              text height=12pt, text depth=6pt, text width=18pt, text centered
              newcommandCayleyTable[2][a]%
              vcenterhboxbegintikzpicture
              pgfmathsetmacrototint(#2-1)
              foreach i in 0,1,...,tot

              node[mynode] (hh-i) at (i *24pt,24pt) ifnumequali0$1$ifnumequali1$#1$$#1^i$;
              node[mynode] (vv-i) at (-24pt-pgflinewidth,-i *24pt) ifnumequali0$1$ifnumequali1$#1$$#1^i$;

              foreach myrow in 0,1,...,tot
              foreach mycol in 0,1,...,tot
              pgfmathsetmacromyplusmyrow+mycolpgfmathsetmacromyexpint(mod(myplus,#2))
              node[mynode] at (myrow*24pt,-mycol*24pt) ifnumequalmyexp0$1$ifnumequalmyexp1$#1$$#1^myexp$;
              draw ([yshift=-2pt]hh-tot.south east) -- ([yshift=-2pt]hh-0.south west) -- ++(-24pt, 0);
              draw ([xshift=2pt]vv-tot.south east) -- ([xshift=2pt]vv-0.north east) -- ++(0,24pt);
              endtikzpicture%

              begindocument
              [
              CayleyTable3
              ]
              [
              CayleyTable[x]4
              ]
              [
              CayleyTable[y]5
              ]
              enddocument


              enter image description here






              share|improve this answer



























                0














                With foreach:



                documentclassarticle
                usepackageetoolbox
                usepackagetikz
                tikzsetmynode/.style=anchor=base,
                inner sep=0pt,
                text height=12pt, text depth=6pt, text width=18pt, text centered
                newcommandCayleyTable[2][a]%
                vcenterhboxbegintikzpicture
                pgfmathsetmacrototint(#2-1)
                foreach i in 0,1,...,tot

                node[mynode] (hh-i) at (i *24pt,24pt) ifnumequali0$1$ifnumequali1$#1$$#1^i$;
                node[mynode] (vv-i) at (-24pt-pgflinewidth,-i *24pt) ifnumequali0$1$ifnumequali1$#1$$#1^i$;

                foreach myrow in 0,1,...,tot
                foreach mycol in 0,1,...,tot
                pgfmathsetmacromyplusmyrow+mycolpgfmathsetmacromyexpint(mod(myplus,#2))
                node[mynode] at (myrow*24pt,-mycol*24pt) ifnumequalmyexp0$1$ifnumequalmyexp1$#1$$#1^myexp$;
                draw ([yshift=-2pt]hh-tot.south east) -- ([yshift=-2pt]hh-0.south west) -- ++(-24pt, 0);
                draw ([xshift=2pt]vv-tot.south east) -- ([xshift=2pt]vv-0.north east) -- ++(0,24pt);
                endtikzpicture%

                begindocument
                [
                CayleyTable3
                ]
                [
                CayleyTable[x]4
                ]
                [
                CayleyTable[y]5
                ]
                enddocument


                enter image description here






                share|improve this answer

























                  0












                  0








                  0







                  With foreach:



                  documentclassarticle
                  usepackageetoolbox
                  usepackagetikz
                  tikzsetmynode/.style=anchor=base,
                  inner sep=0pt,
                  text height=12pt, text depth=6pt, text width=18pt, text centered
                  newcommandCayleyTable[2][a]%
                  vcenterhboxbegintikzpicture
                  pgfmathsetmacrototint(#2-1)
                  foreach i in 0,1,...,tot

                  node[mynode] (hh-i) at (i *24pt,24pt) ifnumequali0$1$ifnumequali1$#1$$#1^i$;
                  node[mynode] (vv-i) at (-24pt-pgflinewidth,-i *24pt) ifnumequali0$1$ifnumequali1$#1$$#1^i$;

                  foreach myrow in 0,1,...,tot
                  foreach mycol in 0,1,...,tot
                  pgfmathsetmacromyplusmyrow+mycolpgfmathsetmacromyexpint(mod(myplus,#2))
                  node[mynode] at (myrow*24pt,-mycol*24pt) ifnumequalmyexp0$1$ifnumequalmyexp1$#1$$#1^myexp$;
                  draw ([yshift=-2pt]hh-tot.south east) -- ([yshift=-2pt]hh-0.south west) -- ++(-24pt, 0);
                  draw ([xshift=2pt]vv-tot.south east) -- ([xshift=2pt]vv-0.north east) -- ++(0,24pt);
                  endtikzpicture%

                  begindocument
                  [
                  CayleyTable3
                  ]
                  [
                  CayleyTable[x]4
                  ]
                  [
                  CayleyTable[y]5
                  ]
                  enddocument


                  enter image description here






                  share|improve this answer













                  With foreach:



                  documentclassarticle
                  usepackageetoolbox
                  usepackagetikz
                  tikzsetmynode/.style=anchor=base,
                  inner sep=0pt,
                  text height=12pt, text depth=6pt, text width=18pt, text centered
                  newcommandCayleyTable[2][a]%
                  vcenterhboxbegintikzpicture
                  pgfmathsetmacrototint(#2-1)
                  foreach i in 0,1,...,tot

                  node[mynode] (hh-i) at (i *24pt,24pt) ifnumequali0$1$ifnumequali1$#1$$#1^i$;
                  node[mynode] (vv-i) at (-24pt-pgflinewidth,-i *24pt) ifnumequali0$1$ifnumequali1$#1$$#1^i$;

                  foreach myrow in 0,1,...,tot
                  foreach mycol in 0,1,...,tot
                  pgfmathsetmacromyplusmyrow+mycolpgfmathsetmacromyexpint(mod(myplus,#2))
                  node[mynode] at (myrow*24pt,-mycol*24pt) ifnumequalmyexp0$1$ifnumequalmyexp1$#1$$#1^myexp$;
                  draw ([yshift=-2pt]hh-tot.south east) -- ([yshift=-2pt]hh-0.south west) -- ++(-24pt, 0);
                  draw ([xshift=2pt]vv-tot.south east) -- ([xshift=2pt]vv-0.north east) -- ++(0,24pt);
                  endtikzpicture%

                  begindocument
                  [
                  CayleyTable3
                  ]
                  [
                  CayleyTable[x]4
                  ]
                  [
                  CayleyTable[y]5
                  ]
                  enddocument


                  enter image description here







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 13 '18 at 20:27









                  CarLaTeXCarLaTeX

                  30.4k448127




                  30.4k448127



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f459639%2fhow-to-draw-a-cayley-table%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Use pre created SQLite database for Android project in kotlin

                      Darth Vader #20

                      Ondo