0

i want to write my latex code as in the image inserted below. Please can someone help me to improve my code here to let them look like in the image.

\begin{multline*}
\begin{bmatrix}
 k_{A,t} \\  k_{BC,t} \\  k_{M,t}  \\   k_{NB,t} \\   k_{NS,t} \\   k_{O,t}  \\  k_{PEI,t}\\  k_{Q,t}\\   k_{S,t}
\end{bmatrix}
=
\begin{bmatrix}
.43&-.03 & .03 & .09 & .03 & .06 & .30&-.11&-.10&-.22\\ 
.0008 & .57 & .12& .19& .08 & .50 &.0035 & -.25 & -.40\\
041 & .15 & -.11 & .30 & .10  & .22& .01 & -.07 & .02\\
.048 &  .10 &.03 & .28  &  .28  &  -.09 & .10 & .17 & -.13\\
.34 &   -.04 & .26&  .05& -.54 & .26 & 0.23 & .10 & .10 \\
.14 &   .20 & -.12 &  -.06 & .01 & .86 & .08 & -.001 & -.17 \\
.038 & -.07 &.07 &  .23 & -.08 & .31& .15 & .32 &-.32\\
.20 & .09 & .12 &-.05 & .04 & .10& .09 & .14 & .701&-.03\\
.14 & .06 & .17 & .32 &  0.25 & 0.12 & -.06 & - .12&-.04\\
\end{bmatrix}
\begin{bmatrix}
 k_{A,t-1} \\   k_{BC,t-1} \\  k_{M,t-1} \\    k_{NB,t-1} \\    k_{NS,t-1} \\     k_{O,t-1} \\    k_{PEI,t-1} \\  k_{Q,t-1} \\  k_{S,t-1}
\end{bmatrix}
+ \\
\begin{bmatrix}
-.26 & -.227 & -.26 &-.23 &.13 &-.05&0.34&-0.05 & -.18 \\ 
%.04 & -.25 & .08 & .20 & .03 & .30 & -.12 & -.09 & -.29\\ 
%.26 & .27 & -1.38 & .44 & -.02 & .12 & .01 & -.06 & .23\\ 
%.46 & .18 & -.23 & -.41 & .14 & -.13 & -.13 & -.01 & -.12\\ 
%.25 & -.19 & -.32 & .44 & -.35 &.52 &.24 &-.19 &-.33\\ 
%.19 & .16 & -.24 & .02 & -.01 & .01 & .03 & -.04 & -.16\\ 
%-.19 & .06 & -.03 & .09 & .24 & -.58 & .36 & -.48 & .002\\ 
%.29 & .04 & -.18 & .13 & .07 & .20& .15 & -.32 & .31\\ 
%.23 & .04 & -.9 & .40 & -.05 & .17 & -.07 & .17 & -.72\\ 
\end{bmatrix}
\begin{bmatrix}
 \lambda 
\end{bmatrix}
+
\begin{bmatrix}
 11.74  \\ 8.59 \\ 10.93 \\  9.46 \\  -8.55 \\  .096 \\ -12.76 \\ -0.37\\  7.91\\
\end{bmatrix}
\end{multline*}

enter image description here

  • 5
    Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – cfr Jul 21 '14 at 22:26
  • ok @cfr i will propose it better the next time. – ntamjo achille Jul 25 '14 at 16:01
2

I use TexStudio version 2.8.0 (download here). It has specialized tools to format code of tables and matrices as shown in Figure (you can use other functions like add or delete rows (or columns))

enter image description here

The button enter image description here arranges the columns by placing the cursor within the respective matrix or tabular environment and clicking. If for some reason as to edit the code the alignment breaks it, repeat the process (click on button). This makes the code more readable.

If you don't want to add missing zeros before of decimal point (you could do this with search and replacement functions of TexStudio), you could try the package siunitx and its macro \num{...} and/or its column specifier S (for array and tabular). This macro aligns columns by decimal point and adds zeros like in .098 i.e \num{.098} -> 0.098. For more information read the siunitx manual.

In my code I used the font package stix for being the most similar to the image and it fits perfectly in portrait mode (without landscape).

Here my code

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{mathtools}
\usepackage{stix}
\begin{document}
\noindent I want to write my latex code as in the image inserted below. Please can someone help me to improve my code here to let them look like in the image.
\begin{align*}
I=\begin{bmatrix}
    k_{1,t} \\
    k_{2,t} \\
    k_{3,t} \\
    k_{4,t} \\
    k_{5,t} \\
    k_{6,t} \\
    k_{7,t} \\
    k_{8,t} \\
    k_{9,t}
\end{bmatrix}
=&
\begin{bmatrix}
    11.74  \\
    8.59   \\
    10.93  \\
    9.46   \\
    -8.55  \\
    0.096  \\
    -12.76 \\
    -0.37  \\
    7.91
\end{bmatrix}
+
\begin{bmatrix}
    0.43   & -0.03 & 0.09  & 0.03  & 0.069 & 0.30  & -0.11 & 0.10   & -0.22 \\
    0.0008 & 0.57  & 0.12  & 0.19  & 0.08  & 0.50  & 0.035 & -0.25  & -0.40 \\
    0.041  & 0.15  & -0.11 & 0.30  & 0.10  & 0.22  & 0.01  & -0.07  & 0.02  \\
    0.048  & 0.10  & 0.03  & 0.28  & 0.28  & -0.09 & 0.10  & 0.17   & -0.13 \\
    0.34   & -0.04 & 0.26  & 0.05  & 0.54  & 0.26  & 0.23  & 0.10   & -0.10 \\
    0.14   & 0.20  & -0.12 & -0.06 & 0.01  & 0.86  & 0.08  & -0.001 & -0.17 \\
    0.038  & -0.07 & 0.07  & 0.23  & -0.08 & 0.31  & 0.15  & 0.32   & -0.32 \\
    0.20   & 0.09  & -0.05 & 0.04  & 0.10  & 0.09  & 0.14  & 0.70   & -0.3  \\
    0.14   & 0.06  & 0.17  & 0.32  & 0.25  & 0.12  & -0.06 & -0.12  & -0.04
\end{bmatrix}
\begin{bmatrix}
    k_{1,t-1} \\
    k_{2,t-1} \\
    k_{3,t-1} \\
    k_{4,t-1} \\
    k_{5,t-1} \\
    k_{6,t-1} \\
    k_{7,t-1} \\
    k_{8,t-1} \\
    k_{9,t-1}
\end{bmatrix}
\\
&\quad + \lambda 
\begin{bmatrix}
    -0.26 \\
    -0.22 \\
    -0.26 \\
    -0.23 \\
    0.13  \\
    -0.05 \\
    0.34  \\
    -0.05 \\
    -0.18
\end{bmatrix}
\end{align*}

\end{document}

And the result

enter image description here

| improve this answer | |
  • What package does the trick of aligning the rows? It is a problem that puzzles me often! Thank you. – Dox Jul 22 '14 at 3:48
  • Do you mean align the columns? there are several packages depending of the alignment you want. array package allows column specifiers lcr, dcolumn supports alignment by the decimal point, etc ... – skpblack Jul 22 '14 at 4:01
  • Not really, I mean row alignment. In the question the metrices have different heights but in your answer, all of them have the same height. How did you achieve that? – Dox Jul 22 '14 at 11:23
1

Left aligned the k vectors. Note the use of \arraystretch and \arraycolsep.

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{mathtools}

\begin{document}
\noindent\rule{\textwidth}{1pt}% show text area

\setlength{\arraycolsep}{2pt}% default is 6pt
\begin{align*}
\left[\begin{array}{l}
 k_{A,t} \\  k_{BC,t} \\  k_{M,t}  \\   k_{NB,t} \\   k_{NS,t} \\   k_{O,t}  \\  k_{PEI,t}\\  k_{Q,t}\\   k_{S,t}
\end{array}\right]
=&
\def\arraystretch{.9}
\begin{bmatrix}
 11.74  \\ 8.59 \\ 10.93 \\  9.46 \\  -8.55 \\  .096 \\ -12.76 \\ -0.37\\  7.91\\
\end{bmatrix}
+
\begin{bmatrix}
.43&-.03 & .09 & .03 & .06 & .30&-.11&-.10&-.22\\ 
.0008 & .57 & .12& .19& .08 & .50 &.0035 & -.25 & -.40\\
041 & .15 & -.11 & .30 & .10  & .22& .01 & -.07 & .02\\
.048 &  .10 &.03 & .28  &  .28  &  -.09 & .10 & .17 & -.13\\
.34 &   -.04 & .26&  .05& -.54 & .26 & 0.23 & .10 & .10 \\
.14 &   .20 & -.12 &  -.06 & .01 & .86 & .08 & -.001 & -.17 \\
.038 & -.07 &.07 &  .23 & -.08 & .31& .15 & .32 &-.32\\
.20 & .09 &-.05 & .04 & .10& .09 & .14 & .701&-.03\\
.14 & .06 & .17 & .32 &  0.25 & 0.12 & -.06 & - .12&-.04\\
\end{bmatrix}
\def\arraystretch{1.0}
\left[\begin{array}{l}
 k_{A,t-1} \\   k_{BC,t-1} \\  k_{M,t-1} \\    k_{NB,t-1} \\    k_{NS,t-1} \\     k_{O,t-1} \\    k_{PEI,t-1} \\  k_{Q,t-1} \\  k_{S,t-1}
\end{array}\right]
\\
&\quad + \lambda 
\def\arraystretch{.9}
\begin{bmatrix}
-.26 \\ -.227 \\ -.26 \\-.23 \\.13 \\-.05\\0.34\\-0.05 \\ -.18 \\ 
%.04 & -.25 & .08 & .20 & .03 & .30 & -.12 & -.09 & -.29\\ 
%.26 & .27 & -1.38 & .44 & -.02 & .12 & .01 & -.06 & .23\\ 
%.46 & .18 & -.23 & -.41 & .14 & -.13 & -.13 & -.01 & -.12\\ 
%.25 & -.19 & -.32 & .44 & -.35 &.52 &.24 &-.19 &-.33\\ 
%.19 & .16 & -.24 & .02 & -.01 & .01 & .03 & -.04 & -.16\\ 
%-.19 & .06 & -.03 & .09 & .24 & -.58 & .36 & -.48 & .002\\ 
%.29 & .04 & -.18 & .13 & .07 & .20& .15 & -.32 & .31\\ 
%.23 & .04 & -.9 & .40 & -.05 & .17 & -.07 & .17 & -.72\\ 
\end{bmatrix}
\end{align*}

\end{document}

matrix eauation

| improve this answer | |
  • Can you find the same font used in the original question image? – skpblack Jul 22 '14 at 0:13
  • Try \small, then try \footnotesize, then try \scriptsize... – John Kormylo Jul 22 '14 at 0:19
  • @skpblack: The font looks like Times New Roman. Try adding \usepackage{mathptmx} to the preamble... – Werner Jul 22 '14 at 0:22
  • @Werner I do not refer the size but the shape, i tried mathptmx but it doesn't seem. Compare \lambda and the 2, 6, 3, 4, ... numbers, they are very differents. – skpblack Jul 22 '14 at 0:29
  • Go to tug.dk/FontCatalogue/mathfonts.html and pick one. – John Kormylo Jul 22 '14 at 2:43

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.