# Very large symbolic matrix - unable to fit either vertically or horizontally

I have a very large symbolic matrix (code below)

I am unable to view the output pdf of the matrix either vertically or horizontally

This how it looks like vertically

This is how it looks like horizontally

I am fine if the page is horizontal, I just need to figure out how to wrap those equations

Can anyone offer a solution so those long equations can be wrapped so enough space can be generated to fit the entire matrix onto the page?

% !TeX program = xelatex
\documentclass[12pt]{article}
\usepackage{fontspec}
\usepackage[12pt]{moresize}
% This first part of the file is called the PREAMBLE. It includes
% customizations and command definitions. The preamble is everything
% between \documentclass and \begin{document}.

\usepackage[margin=1in]{geometry}  % set the margins to 1in on all sides
%\usepackage[draft]{graphicx}              % to include figures
\usepackage{graphicx}
\usepackage{amsmath}               % great math stuff
\usepackage{amsfonts}              % for blackboard bold, etc
\usepackage{amsthm}                % better theorem environments
\usepackage{amssymb}
\usepackage{mathrsfs}
\usepackage{upgreek}
\usepackage{dsfont}               %to use mathds(1)
\usepackage{cancel}
\usepackage{pdflscape}
\usepackage{graphicx}
\usepackage{changepage}
\usepackage{stackengine}
\setcounter{MaxMatrixCols}{20}

\allowdisplaybreaks
\title{Very Large Matrix, How?}

\begin{document}

\begin{landscape}
\begin{equation*}
M = \begin{bmatrix} -k-k_1-k_2 & -x & 0 & 0 & 0 & 0 & 0 & k_1 & z & x & 0\\
c & k_1 - d_2*y*x   & 0 & 0 & 0 & 0 & (d*k*x)/(2*x_7^{1/2}) - (d*k*x)/y  & d_2*k_2*x_7^(1/2) - k_1 & 0 & 0 & 0\\
0 & 0 & -k*-y - k_3 & 0 & 0 & 0 & 0 & k*u*xy^(1/2)*x)*y^2 - (d*k*x_3^(1/2)*x)*y^2 & 0 & 0 & 0
\end{bmatrix}
\end{equation*}
\end{landscape}

\end{document}

• There's a problem with your code: you seem to believe things like is coded x^(1/2) (with parentheses) instead of x^{1/2} (with braces), and the parentheses do not come in pairs anyway, so we"re not sure of what you want. Could you post a correct code? Sep 27 '16 at 22:07
• Do some * in the formula have to be typed as superscripts? Sep 27 '16 at 22:14
• Does * mean multiplication? If so, why isn't it omitted as customary? Sep 27 '16 at 22:18
• @Bernard Sorry about that, this matrix was copied and pasted from another source and definitely is not latex. The actual matrix is 15 x 11 not what you see here....it is way too big so I only copied the first three rows and converted some of the elements into latex form while turned the rest into zeroes. But I think Zarko has provided very good solution for this problem. Sep 28 '16 at 1:44

You have two options:

• split long math expression into two lines
• introduce new variables which meaning you explain in text:

\documentclass[12pt]{article}
\usepackage{fontspec}
\usepackage[12pt]{moresize}

\usepackage[margin=1in]{geometry}  % set the margins to 1in on all sides
\usepackage{mathtools}             % great math stuff
\usepackage{pdflscape}
\setcounter{MaxMatrixCols}{20}

\begin{document}
\begin{landscape}
splitting long math expression into two line:
\begin{equation*}
M = \begin{bmatrix}
-k-k_1-k_2  & -x            & 0 & 0 & 0 & 0 & 0 & k_1 & z & x & 0\\[2ex]
c           & k_1 - d_2*y*x & 0 & 0 & 0 & 0 &
\begin{multlined}
(d*k*x)/(2*x_7^{1/2})   \\[-2ex]
- (d*k*x)/y
\end{multlined}                     & d_2*k_2*x_7^{1/2} - k_1 & 0 & 0 & 0\\[2ex]
0 & 0 & -k*-y - k_3 & 0 & 0 & 0 & 0 &
\begin{multlined}
k*u*xy^{1/2}*x)*y^2         \\[-2ex]
- (d*k*x_3^{1/2}*x)*y^2
\end{multlined}                 & 0 & 0 & 0
\end{bmatrix}
\end{equation*}

more elegant option:
\begin{equation*}
M = \begin{bmatrix}
-k-k_1-k_2  & -x            & 0 & 0 & 0 & 0 & 0 & k_1 & z & x & 0\\
c           & k_1 - d_2*y*x & 0 & 0 & 0 & 0 & A & B   & 0 & 0 & 0\\
0           & 0             & -k*-y - k_3
& 0 & 0 & 0 & 0 & C   & 0 & 0 & 0
\end{bmatrix}
\end{equation*}
where are $A=(d*k*x)/(2*x_7^{1/2}) - (d*k*x)/y$, $B=d_2*k_2*x_7^{1/2} - k_1$
and $C=k*u*xy^{1/2}*x)*y^2 - (d*k*x_3^{1/2}*x)*y^2$ respectively.
\end{landscape}
\end{document}