The action of any controlled gate is to do nothing (i.e. apply the identity operation) if the control qubit is in $\vert 0\rangle$ and apply an operation $U$ on the target when the control is in $\vert 1\rangle$. All other qubits in the system are also left untouched (i.e. apply the identity operation).
Use the subscripts $c$ and $t$ for the control qubit and target qubit. The gate looks like this
$$ I_1\otimes I_2\otimes... \otimes\vert 0\rangle\langle 0\vert_c \otimes... \otimes\ I_t\ \otimes...\otimes I_n \ \ +\ \ I_1\otimes I_2\otimes... \otimes\vert 1\rangle\langle 1\vert_c \otimes... \otimes\ U_t\ \otimes...\otimes I_n$$
In matrix form, this is just
$$\begin{pmatrix}1&0\\ 0&1\end{pmatrix}_1\otimes \begin{pmatrix}1 & 0\\ 0&1 \end{pmatrix}_2 \otimes ... \otimes\begin{pmatrix}1 & 0\\ 0&0 \end{pmatrix}_c \otimes ... \otimes\begin{pmatrix}1 & 0\\ 0&1 \end{pmatrix}_t\otimes... \otimes \begin{pmatrix}1 & 0\\ 0&1 \end{pmatrix}_n \\
+ \begin{pmatrix}1&0\\ 0&1\end{pmatrix}_1\otimes \begin{pmatrix}1 & 0\\ 0&1 \end{pmatrix}_2 \otimes ... \otimes\begin{pmatrix}0 & 0\\ 0 & 1 \end{pmatrix}_c \otimes ... \otimes\begin{pmatrix}u_{11} & u_{12}\\ u_{21}& u_{22} \end{pmatrix}_t\otimes... \otimes \begin{pmatrix}1 & 0\\ 0&1 \end{pmatrix}_n $$
A simple example to help is when you only have two qubits, $t$ corresponds to the first qubit and $c$ corresponds to the second qubit. Then you have
$$ I\otimes \vert 0\rangle\langle 0\vert + U\otimes \vert 1\rangle\langle 1\vert.$$
The matrix form is
$$\begin{pmatrix}
1 & 0 & 0 & 0\\
0 & u_{11} & 0 & u_{12}\\
0& 0& 1 & 0\\
0 & u_{21} & 0 & u_{22}
\end{pmatrix}$$