1

I have in my latex document included a matrix that does not fit the width of my page. For this reason, I include it in mathmode and then apply the scalemath command for it. The typesetting goes well, however, for some reason, a 't' appears in front of the matrix. I have tried some things but could not resolve the issue...

MWE:

\documentclass[11pt, oneside]{report}
%\renewcommand{\baselinestretch}{1.5}       % use "amsart" instead of "article" for AMSLaTeX format
\usepackage{geometry}  
                % See geometry.pdf to learn the layout options. There are lots.
\geometry{letterpaper}                          % ... or a4paper or a5paper or ... 
%\geometry{landscape}                       % Activate for rotated page geometry
%\usepackage[parfill]{parskip}          % Activate to begin paragraphs with an empty line rather than an indent
\usepackage{graphicx}               % Use pdf, png, jpg, or eps§ with pdflatex; use eps in DVI mode
\usepackage{eqnarray,amsmath}
                    % TeX will automatically convert eps --> pdf in pdflatex        
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{mathtools}
\usepackage{setspace}
\singlespacing
%\onehalfspacing
\usepackage[T1]{fontenc}
\usepackage{subcaption}
\usepackage{pdflscape} 
\usepackage{pdfpages}
\usepackage{etoolbox}
\usepackage{pdfpages}
\usepackage{atbegshi}
\makeatletter
\usepackage{capt-of}
\usepackage[utf8]{inputenc} % Any characters can be typed directly from the keyboard, eg éçñ
\usepackage{textcomp} % provide lots of new symibols
\usepackage{graphicx}  % Add graphics capabilities
\usepackage{flafter}  % Don't place floats before their definition
\usepackage{amsmath,calc}
\usepackage{amsmath,amssymb}  % Better maths support & more symbols
\usepackage{bm}  % Define \bm{} to use bold math fonts
\usepackage{hyperref}
\usepackage{caption}
\usepackage{titlesec}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{rotating}
\usepackage[babel]{csquotes}
\usepackage[backend=biber]{biblatex}
\addbibresource{library.bib} % with extension
\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{4}
\usepackage{memhfixc}
% \usepackage[activate]{pdfcprot}
\usepackage{pdfsync}
\begin{document}

$$
\scalemath{0.75}{\begin{pmatrix}
- \frac{x_1}{c_t} \cdot \left( \frac{1}{\mathcal{D}_{12}} + \frac{1}{\mathcal{D}_{13}} \right)  - \frac{x_2}{c_t \cdot \mathcal{D}_{12}} - \frac{x_3}{c_t \cdot \mathcal{D}_{13}} & \frac{x_1}{c_t} \cdot \left(\frac{1}{\mathcal{D}_{12}} - \frac{1}{\mathcal{D}_{13}} \right) & \frac{x_1}{c_t} \cdot \left( \frac{1}{\mathcal{D}_{13}} - \frac{1}{\mathcal{D}_{12}}\right) \\ 
 \frac{x_2}{c_t} \cdot \left(\frac{1}{\mathcal{D}_{21}} - \frac{1}{\mathcal{D}_{23}} \right) & - \frac{x_2}{c_t} \cdot \left( \frac{1}{\mathcal{D}_{21}} + \frac{1}{\mathcal{D}_{23}} \right)  - \frac{x_1}{c_t \cdot \mathcal{D}_{21}} - \frac{x_3}{c_t \cdot \mathcal{D}_{23}} & \frac{x_2}{c_t} \cdot \left(\frac{1}{\mathcal{D}_{23}} - \frac{1}{\mathcal{D}_{21}} \right) \\
 \frac{x_3}{c_t} \cdot \left(\frac{1}{\mathcal{D}_{31}} - \frac{1}{\mathcal{D}_{32}} \right) & \frac{x_3}{c_t} \cdot \left(\frac{1}{\mathcal{D}_{32}} - \frac{1}{\mathcal{D}_{31}} \right) & - \frac{x_3}{c_t} \cdot \left( \frac{1}{\mathcal{D}_{31}} + \frac{1}{\mathcal{D}_{32}} \right)  - \frac{x_1}{c_t \cdot \mathcal{D}_{31}} - \frac{x_2}{c_t \cdot \mathcal{D}_{32}} 
\end{pmatrix}}
$$

\end{document}
  • 1
    your example is far from minimal (do you really need atbegshi and siunitx and biblatex and... to demonstrate the problem? and it gives the error ! Undefined control sequence. l.52 \scalemath – David Carlisle May 16 '17 at 10:17
  • Note that pdfsync is very obsolete. Avoid it. – egreg May 16 '17 at 11:49
3

Split the matrix into two:

\documentclass[11pt, oneside]{report}
\usepackage{geometry}  
\geometry{letterpaper}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{bm}

\begin{document}

\begin{multline*}
\begin{pmatrix}
-\frac{x_1}{c_t} \left(\frac{1}{\mathcal{D}_{12}} + \frac{1}{\mathcal{D}_{13}}\right) &
 \frac{x_1}{c_t} \left(\frac{1}{\mathcal{D}_{12}} - \frac{1}{\mathcal{D}_{13}}\right) &
 \frac{x_1}{c_t} \left(\frac{1}{\mathcal{D}_{13}} - \frac{1}{\mathcal{D}_{12}}\right) \\[2ex]
 \frac{x_2}{c_t} \left(\frac{1}{\mathcal{D}_{21}} - \frac{1}{\mathcal{D}_{23}}\right) &
-\frac{x_2}{c_t} \left(\frac{1}{\mathcal{D}_{21}} + \frac{1}{\mathcal{D}_{23}}\right) &
 \frac{x_2}{c_t} \left(\frac{1}{\mathcal{D}_{23}} - \frac{1}{\mathcal{D}_{21}}\right) \\[2ex]
 \frac{x_3}{c_t} \left(\frac{1}{\mathcal{D}_{31}} - \frac{1}{\mathcal{D}_{32}}\right) &
 \frac{x_3}{c_t} \left(\frac{1}{\mathcal{D}_{32}} - \frac{1}{\mathcal{D}_{31}}\right) &
-\frac{x_3}{c_t} \left(\frac{1}{\mathcal{D}_{31}} + \frac{1}{\mathcal{D}_{32}}\right)
\end{pmatrix}
\\[2ex]
-\begin{pmatrix}
\frac{x_2}{c_t \cdot \mathcal{D}_{12}} + \frac{x_3}{c_t \cdot \mathcal{D}_{13}} & 0 & 0 \\[2ex]
0 & \frac{x_1}{c_t \cdot \mathcal{D}_{21}} + \frac{x_3}{c_t \cdot \mathcal{D}_{23}} & 0 \\[2ex]
0 & 0 & \frac{x_1}{c_t \cdot \mathcal{D}_{31}} + \frac{x_2}{c_t \cdot \mathcal{D}_{32}}
\end{pmatrix}
\end{multline*}

\begin{multline*}
\begin{pmatrix}
-\dfrac{x_1}{c_t} \left(\dfrac{1}{\mathcal{D}_{12}} + \dfrac{1}{\mathcal{D}_{13}}\right) &
 \dfrac{x_1}{c_t} \left(\dfrac{1}{\mathcal{D}_{12}} - \dfrac{1}{\mathcal{D}_{13}}\right) &
 \dfrac{x_1}{c_t} \left(\dfrac{1}{\mathcal{D}_{13}} - \dfrac{1}{\mathcal{D}_{12}}\right) \\[3ex]
 \dfrac{x_2}{c_t} \left(\dfrac{1}{\mathcal{D}_{21}} - \dfrac{1}{\mathcal{D}_{23}}\right) &
-\dfrac{x_2}{c_t} \left(\dfrac{1}{\mathcal{D}_{21}} + \dfrac{1}{\mathcal{D}_{23}}\right) &
 \dfrac{x_2}{c_t} \left(\dfrac{1}{\mathcal{D}_{23}} - \dfrac{1}{\mathcal{D}_{21}}\right) \\[3ex]
 \dfrac{x_3}{c_t} \left(\dfrac{1}{\mathcal{D}_{31}} - \dfrac{1}{\mathcal{D}_{32}}\right) &
 \dfrac{x_3}{c_t} \left(\dfrac{1}{\mathcal{D}_{32}} - \dfrac{1}{\mathcal{D}_{31}}\right) &
-\dfrac{x_3}{c_t} \left(\dfrac{1}{\mathcal{D}_{31}} + \dfrac{1}{\mathcal{D}_{32}}\right)
\end{pmatrix}
\\[2ex]
-\begin{pmatrix}
\dfrac{x_2}{c_t \cdot \mathcal{D}_{12}} + \dfrac{x_3}{c_t \cdot \mathcal{D}_{13}} & 0 & 0 \\[2ex]
0 & \dfrac{x_1}{c_t \cdot \mathcal{D}_{21}} + \dfrac{x_3}{c_t \cdot \mathcal{D}_{23}} & 0 \\[2ex]
0 & 0 & \dfrac{x_1}{c_t \cdot \mathcal{D}_{31}} + \dfrac{x_2}{c_t \cdot \mathcal{D}_{32}}
\end{pmatrix}
\end{multline*}

\end{document}

I gave two examples and probably would choose the latter, with bigger fractions, as the text width seems to allow it.

enter image description here

About your preamble: it's messy and packages are loaded multiple times. Reordering it is a need.

  1. pdfsync is way obsolete and invasive; avoid it
  2. hyperref should be loaded last
  3. $$ should never be used in LaTeX

Here's a possible reshaping.

\documentclass[11pt, oneside]{report}

% text input and output
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}

% pages and text
\usepackage{geometry}  
%\usepackage[parfill]{parskip}          % Activate to begin paragraphs with an empty line rather than an indent
\usepackage{setspace}

% math
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{bm}  % Define \bm{} to use bold math fonts

% tables and floats
\usepackage{caption}
\usepackage{subcaption}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{flafter}  % Don't place floats before their definition

% utilities
\usepackage{graphicx}
\usepackage{rotating}
\usepackage{pdflscape} 
\usepackage{pdfpages}
\usepackage{etoolbox}
\usepackage{calc}
\usepackage{atbegshi}
%\usepackage[activate]{pdfcprot}
%\usepackage{memhfixc} % it's for memoir

\usepackage{titlesec}

% bibliography
\usepackage[babel]{csquotes}
\usepackage[backend=biber]{biblatex}

% hyperlinks
\usepackage{hyperref}

%%% Settings

% spacing
\singlespacing
%\onehalfspacing

% bibliography
\addbibresource{library.bib} % with extension

% numbering
\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{4}

%%% Personal commands

\begin{document}
2

Unless you can find a way to simplify or abbreviate the expressions along the main diagonal of the matrix, your best bet might be to display the three column vectors that make up the matrix separately.

enter image description here

\documentclass{article}
\usepackage{mathtools,bm}
\usepackage{geometry} 
\begin{document}
Let $\bm{A}=\begin{pmatrix*} \bm{a}_1 & \bm{a}_2 &\bm{a}_3 \end{pmatrix*}$, with
\begin{align*}
\bm{a}_1 &= \begin{pmatrix*}[l]
            - \frac{x_1}{c_t}  \bigl( \frac{1}{\mathcal{D}_{12}} + \frac{1}{\mathcal{D}_{13}} \bigr)  
               - \frac{x_2}{c_t  \mathcal{D}_{12}} - \frac{x_3}{c_t  \mathcal{D}_{13}} \\[1ex]
            \phantom{-}\frac{x_2}{c_t}  \bigl(\frac{1}{\mathcal{D}_{21}} - \frac{1}{\mathcal{D}_{23}} \bigr) \\[1ex]
            \phantom{-}\frac{x_3}{c_t}  \bigl(\frac{1}{\mathcal{D}_{31}} - \frac{1}{\mathcal{D}_{32}} \bigr)
            \end{pmatrix*} \\[1ex]
\bm{a}_2 &= \begin{pmatrix*}[l]
            \phantom{-}\frac{x_1}{c_t}  \bigl(\frac{1}{\mathcal{D}_{12}} - \frac{1}{\mathcal{D}_{13}} \bigr) \\[1ex]
            - \frac{x_2}{c_t}  \bigl( \frac{1}{\mathcal{D}_{21}} + \frac{1}{\mathcal{D}_{23}} \bigr)  
               - \frac{x_1}{c_t  \mathcal{D}_{21}} - \frac{x_3}{c_t  \mathcal{D}_{23}} \\[1ex]
            \phantom{-}\frac{x_3}{c_t}  \bigl(\frac{1}{\mathcal{D}_{32}} - \frac{1}{\mathcal{D}_{31}} \bigr)
            \end{pmatrix*} \\[1ex]
\bm{a}_2 &= \begin{pmatrix*}[l]
            \phantom{-}\frac{x_1}{c_t}  \bigl( \frac{1}{\mathcal{D}_{13}} - \frac{1}{\mathcal{D}_{12}}\bigr) \\[1ex]
            \phantom{-}\frac{x_2}{c_t}  \bigl(\frac{1}{\mathcal{D}_{23}} - \frac{1}{\mathcal{D}_{21}} \bigr) \\[1ex]
           - \frac{x_3}{c_t}  \bigl( \frac{1}{\mathcal{D}_{31}} + \frac{1}{\mathcal{D}_{32}} \bigr)  
              - \frac{x_1}{c_t  \mathcal{D}_{31}} - \frac{x_2}{c_t  \mathcal{D}_{32}}
           \end{pmatrix*}
\end{align*} 
\end{document}
0

Your matrix can fit the margins, due to its particular structure (very large elements on the diagonal only) using the dium-sized command from nccmath (~ 80% of \displaystyle):

\documentclass[11pt, oneside]{report}
\usepackage[utf8]{inputenc} % Any characters can be typed directly from the keyboard, eg éçñ
\usepackage[T1]{fontenc}
\usepackage{geometry}
\usepackage{pdflscape}
                % See geometry.pdf to learn the layout options. There are lots.
\geometry{letterpaper, showframe} % \dots or a4paper or a5paper or ...
                    % TeX will automatically convert eps --> pdf in pdflatex
\usepackage{amssymb}
\usepackage{bm} % Define \bm{} to use bold math fonts
\usepackage{textcomp} % provide lots of new symbols
\usepackage{mathtools, nccmath}

\begin{document}

Normal text. Normal text. Normal text. Normal text. Normal text. Normal text. Normal text. Normal text.
\[
  \medmath{\begin{pmatrix}
      - \mfrac{x_1}{c_t} \left( \mfrac{1}{\mathcal{D}_{12}} + \mfrac{1}{\mathcal{D}_{13}} \right) - \mfrac{x_2}{c_t \mathcal{D}_{12}} - \mfrac{x_3}{c_t \mathcal{D}_{13}} & \mfrac{x_1}{c_t} \left(\mfrac{1}{\mathcal{D}_{12}} - \mfrac{1}{\mathcal{D}_{13}} \right)                                                                                                               & \mfrac{ x_1}{c_t} \left( \mfrac{1}{\mathcal{D}_{13}} - \mfrac{1}{\mathcal{D}_{12}}\right)                                                                           \\[3ex]
      \mfrac{x_2}{c_t} \left(\mfrac{1}{\mathcal{D}_{21}} - \mfrac{1}{\mathcal{D}_{23}} \right)                                                                            & \hspace*{-1.75em}- \mfrac{x_2}{c_t} \left( \mfrac{1}{\mathcal{D}_{21}} + \mfrac{1}{\mathcal{D}_{23}} \right) - \mfrac{x_1}{c_t \mathcal{D}_{21}} - \mfrac{x_3}{c_t \mathcal{D}_{23}} \hspace*{-1.75em} & \mfrac{x_2}{c_t} \left(\mfrac{1}{\mathcal{D}_{23}} - \mfrac{1}{\mathcal{D}_{21}} \right)                                                                            \\[3ex]
      \mfrac{x_3}{c_t} \left(\mfrac{1}{\mathcal{D}_{31}} - \mfrac{1}{\mathcal{D}_{32}} \right)                                                                            & \mfrac{x_3}{c_t} \left(\mfrac{1}{\mathcal{D}_{32}} - \mfrac{1}{\mathcal{D}_{31}} \right)                                                                                                               & - \mfrac{x_3}{c_t} \left( \mfrac{1}{\mathcal{D}_{31}} + \mfrac{1}{\mathcal{D}_{32}} \right) - \mfrac{x_1}{c_t \mathcal{D}_{31}} - \mfrac{x_2}{c_t \mathcal{D}_{32}}
    \end{pmatrix}}
\]

\end{document}

enter image description here

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.