why textbf doesn't work when writing between dollar signs between the curly brackets?

I'm trying to write the following but in bold: $M_s$ so that the "s" becomes next to "M" but low and i have the following code:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}
\title{Fundamentals of informatics A4}
\author{some name}
\date{January 2018}

\setlength{\parindent}{0pt}
\begin{document}
% some text

into a new Turing machine \textbf{$M_s$} with the following behavior:

%some more text

\end{document}


The problem is that the M_s wouldn't appear bold no matter what i try

edit1: \textbf{} works perfectly with just text but when using the dollar signs, it doesn't.

• Well, \textbf is meant for text mode, not for content in math mode. You can try {\boldmath $M_s$} – user31729 Jan 11 '18 at 8:28
• Use $\mathbf{M_s}$ for upright M or \boldmath $M_s$\unboldmath – user2478 Jan 11 '18 at 8:32

Use the bm package and type $\bm{M_s}$ to get what you want. The command \textbf is for ordinary text, not for mathematical text.

You could define a command that automatically bolds text and math:

\newcommand{\textmathbf}[1]{\textbf{\boldmath#1}}


However, your question seems like you just want to have the s as an index to M and don't necessarily want them in math mode, so you might want to use:

\textbf{$\text{M}_\text{s}$} %% requires \usepackage{amsmath}


If it's in text mode, use \textbf{}.
If it's in math mode, use \mathbf{}.

Here's the distinction:

into a \textbf{new} Turing machine $\mathbf{M_s}$ with the following behavior: