I want to fit the "N-1" into the box below if possible; if I use the solution \text{-}, namely 3/{N\text{-}1}, it gives me an error: Undefined control sequence: } (followed by: )
Is there a way to fix?
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc, positioning}
\def\d{0.7cm}
\tikzset{
>=latex,
font=\sffamily,
mybox/.style={rectangle, fill=white, thin, draw, outer sep=0, minimum width = \d, minimum height = \d, inner sep=0},
}
\begin{document}
\begin{tikzpicture}
\foreach\k/\s in {
0/1, 3/{N-1}, 4/{N}
}{
\node[mybox] (bc\k) at ($(-\k*\d, 0)$) {$S_{\s}$};
}
\end{tikzpicture}
\end{document}


\textisn't defined. Use\textupinstead of\textand it will work. – Hood Chatham Jan 19 '18 at 17:55font=\sffamily\small– Ignasi Jan 19 '18 at 17:56\textup{-}is a hyphen. yes, it is narrower than a minus, but it is also not at the same height. – barbara beeton Jan 19 '18 at 18:15