1

I put a matrix expression in a table. Now I'm trying to insert a caption, but I obtain an error and caption don't appear in my pdf. This is my code:

\begin{table*}
\[
\begin{bmatrix}
y_\triangle \\
y
\end{bmatrix}
\Large
=
\renewcommand\arraystretch{2}
\begin{bmatrix}[c|ccc]
- \frac{\omega_i C C_{dyn} H G}{1+C C_{dyn} H G} & \frac{\omega_i C C_{dyn}}{1+C C_{dyn} H G} & \frac{\omega_i}{1+C C_{dyn} H G} & - \frac{\omega_i C C_{dyn} H}{1+C C_{dyn} H G} \\ \hline
\frac{\omega_p G}{1+C C_{dyn} H G} & \frac{\omega_p C C_{dyn} G}{1+C C_{dyn} H G} & \frac{\omega_p G}{1+C C_{dyn} H G} & - \frac{\omega_p C C_{dyn} H G}{1+C C_{dyn} H G}
\end{bmatrix}
\normalsize
\renewcommand\arraystretch{1}
\begin{bmatrix}
u_\triangle \\
r\\
\omega \\
n
\end{bmatrix}
\]
\caption{Trasformata U_LFT del sistema}
\label{fig:ulft}
\end{table*}

In the preamble I inserted this code for insert vertical line in the matrix.

\makeatletter
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
  \hskip -\arraycolsep
  \let\@ifnextchar\new@ifnextchar
  \array{#1}}
\makeatother

Thanks to everybody for help

5
  • The instruction\begin{bmatrix}[c|ccc] can't be correct. Did you mean to write \left[ \begin{array}{c|ccc} instead -- and \end{array}\right] instead of \end{bmatrix}? What, incidentally, is the (mathematical) purpose of the vertical line, as well as of the \hline directive that's in your code? – Mico Jan 23 '17 at 11:34
  • @Mico Try adding the \renewcommand*\env@matrix code to your preamble, to see that [c|ccc] works, – Torbjørn T. Jan 23 '17 at 11:45
  • Thanks for answer. I need vertical and horizontal line because this is transfer matrix of an automated system composed by 4 sub-system which I highlight using these lines. Using code I inserted in preamble I'm able to insert vertical line in matrix. I copy the code by another post in this forum [link] (tex.stackexchange.com/questions/33519/…). My problem is on caption. It donesn't appear in my pdf – Ruben Jan 23 '17 at 12:01
  • @TorbjørnT. - Thanks for pointing out the importance of the \renewcommand*\env@matrix code; I had completely missed it. That said, the \hline that's generated by the OP's code is much too long. – Mico Jan 23 '17 at 12:03
  • @Ruben - I've provided an addendum to my answer to suggest an approach that uses an array environment. – Mico Jan 23 '17 at 12:15
3

To get rid of the error message generated by the caption, change _ to \_ in the argument of \caption.

You also should contemplate fixing several other issues. Do get rid of the font size changes within the formula, the \hline directive, and the changes to \arraystretch. Use \dfrac instead of \frac if you want larger fraction terms.

enter image description here

\documentclass{article}
\usepackage[italian]{babel}
\usepackage{amsmath} % for 'bmatrix' environment and '\dfrac' macro
\usepackage[a4paper,margin=2.5cm]{geometry} % set page and text block parameters
\begin{document}
\begin{table}
\[
\begin{bmatrix} y_\triangle \\ y \end{bmatrix}
%%%\Large
=
%%%\renewcommand\arraystretch{2}
\begin{bmatrix}%%%[c|ccc]
-\dfrac{\omega_i C C_{\mathrm{dyn}} H G}{1+C C_{\mathrm{dyn}} H G} & 
 \dfrac{\omega_i C C_{\mathrm{dyn}}}{1+C C_{\mathrm{dyn}} H G} & 
 \dfrac{\omega_i}{1+C C_{\mathrm{dyn}} H G} & 
-\dfrac{\omega_i C C_{\mathrm{dyn}} H}{1+C C_{\mathrm{dyn}} H G} \\[3ex] %%%\hline
 \dfrac{\omega_p G}{1+C C_{\mathrm{dyn}} H G} & 
 \dfrac{\omega_p C C_{\mathrm{dyn}} G}{1+C C_{\mathrm{dyn}} H G} & 
 \dfrac{\omega_p G}{1+C C_{\mathrm{dyn}} H G} & 
-\dfrac{\omega_p C C_{\mathrm{dyn}} H G}{1+C C_{\mathrm{dyn}} H G}
\end{bmatrix}
%%%\normalsize
%%%\renewcommand\arraystretch{1}
\begin{bmatrix} u_\triangle \\ r\\ \omega \\ n \end{bmatrix}
\]
\caption{Trasformata U\_LFT del sistema} % <--- change "_" to "\_"
\label{fig:ulft}
\end{table}
\end{document}

Addendum: If you must insert a vertical and a horizontal line in the 2x4 matrix, I suggest you do so by using an array environment, rather than a bmatrix environment. That way, you won't have \hline generating a line that's too long and ends up interfering with the square brackets.

\left[ \begin{array}{@{}c|ccc@{}}
-\dfrac{\omega_i C C_{\mathrm{dyn}} H G}{1+C C_{\mathrm{dyn}} H G} & 
\dfrac{\omega_i C C_{\mathrm{dyn}}}{1+C C_{\mathrm{dyn}} H G} & 
\dfrac{\omega_i}{1+C C_{\mathrm{dyn}} H G} & 
- \dfrac{\omega_i C C_{\mathrm{dyn}} H}{1+C C_{\mathrm{dyn}} H G} \\[2ex]
\hline 
% use '\mathstrut' to get a bit more vertical separation:
\dfrac{\omega_p G^{\mathstrut}}{1+C C_{\mathrm{dyn}} H G} & 
\dfrac{\omega_p C C_{\mathrm{dyn}} G}{1+C C_{\mathrm{dyn}} H G} & 
\dfrac{\omega_p G}{1+C C_{\mathrm{dyn}} H G} & 
- \dfrac{\omega_p C C_{\mathrm{dyn}} H G}{1+C C_{\mathrm{dyn}} H G}
\end{array}\right]
2
  • It was a stupid error by me. Thanks a lot!!! I was desperate. – Ruben Jan 23 '17 at 12:03
  • thanks for your precious suggestions and for use your time for help me. Code is very "clean" now and result is amazing. I like it. Thanks a lot again!! – Ruben Jan 23 '17 at 12:25

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.