5

I have what's below and I do not know why the term m_{n+1,k} is not horizontally centered in its cell?

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{matrix,positioning}
\begin{document}
\begin{tikzpicture}[baseline=(current  bounding  box.center)]
\tikzset{square matrix/.style={outer sep=-6pt,matrix of nodes,
nodes={draw,
minimum height=0.7cm,
anchor=center,
text width=0.7cm,
align=center,
outer sep=-6pt}}}
\matrix(mymatrix)[square matrix,left delimiter={[},right delimiter={]}]{
1 & 0\\
0 & $-m_{n+1,k}$\\};
\end{tikzpicture}
\end{document} 
  • Because you specified text width, so the cell can't become large enough to accommodate the whole text. Try minimum width instead. Side question: Do you actually want the node borders to be drawn, or is this just for testing purposes? – Jake Feb 9 '12 at 22:01
  • borders are here for testing purposes. I'll give the minimum width option a try. Thank you – pluton Feb 10 '12 at 1:53
  • Just remove the text width=0.7cm and it will center automatically anyway or reduce the font size with \scriptscriptstyle. Otherwise you will be overprinting. – percusse Feb 10 '12 at 15:29
2

ok, the minimum width option helps but I am now using a \makebox[0pt][c]{$-m_{k+1,n}$} to get the desired matrix.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.