[Solved] Text alignment in Tikz nodes with linebreaks just wont work

Felix Asks: Text alignment in Tikz nodes with linebreaks just wont work
I am really sorry to bother you guys with this standard sounding question, but I am desperate and can’t solve it. I’ve read every thread on tex.sx about this that I could find and yet, I can’t get this under control. So here is the thing:

I want to place a two lines text inside each node in a grid and want them to be centered. Now I am aware of this among other threads. E.g. the most natural solution would be to use align=center in combination with linebreaks \ inside the node text brackets.

Picture and MWE below. As you can see, the letters are not centered, while the numbering is. I tried:

  • align + \
  • text width, alone and in combination with the above
  • tabular environment inside the node text brackets
  • removing the scriptsize parameter I use As you can see, I use nested for loops to create a grid that counts up in a serpentine formation. Certain groups of indices (predefined externally) receiver certain letters, I achieve this with the defined command mylabel. Got the idea for this from my question earlier. However, I just cant get the letters to align centered with the numbers in the line below. Can anybody help?

enter image description here



  foreachc in {0,...,15}
    ifnum num = temp scriptsize Cfi
  foreacha in {0,...,63}
    ifnum num = temp scriptsize Afi
  foreachh in {0,...,6}
    ifnum num = temp scriptsize Hfi
  ifnum num = 89 scriptsize Ofi 

begin{tikzpicture}[node distance=1cm]

foreach i in {0,...,7}
  foreach j in {0,...,10}
    {pgfmathsetmacro{x}{1*j*(-1)^(i) + 5*(-1)^(i+1)}
    node (elabel) [rectangle, draw=black, minimum width=1cm, align=center] at (x,-1*i) {


Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.