3

This is the latex code that I am using to create three equations. I want to reduce the length of the second equation to fit in a single column.

How can I resize or scale only the second equation in this code ? Is it possible to just change the font size ?

Which one would be better ?

Packages needed to run this are :

\usepackage{amsmath,amssymb}
\usepackage{mathtools}

The code:

\begin{flalign}
\notag J_{G}(\textbf{x}) &= \frac{\partial G}{\partial \textbf{x}} = \frac{\partial }{\partial \textbf{x}}(\mathbf{RP_{i}+T-Q_{i}})\\
\notagJ_{G}(\mathbf{x})&=\frac{\partial }{\partial \mathbf{x}}\left ( \begin{bmatrix}
r_{11} & r_{12} & r_{13}\\ 
r_{21} & r_{22} & r_{23}\\ 
r_{31} & r_{32} & r_{33}
\end{bmatrix} \begin{bmatrix}
P_{ix}\\ 
P_{iy}\\ 
P_{iz}
\end{bmatrix} + \begin{bmatrix}
x\\ 
y\\ 
z
\end{bmatrix} - \begin{bmatrix}
Q_{ix}\\ 
Q_{iy}\\ 
Q_{iz}
\end{bmatrix}\right ) = \begin{bmatrix}
1\\ 
0\\ 
0
\end{bmatrix}\\
\notag \frac{\partial J_{i}}{\partial \mathbf{x}} &= 2 \cdot \begin{bmatrix}
1 & 0 & 0
\end{bmatrix} \cdot \left [ \left [ \mathbf{RP_{i}+T} \right ]-\begin{bmatrix}
Q_{ix}\\ 
Q_{iy}\\ 
Q_{iz}
\end{bmatrix} \right ]
\end{flalign}

Thank you!

5
  • please always post a complete document so people can run the file locally and see the problem. In particular "fit in column" depends on the column width which you have not shown. Commented Dec 19, 2014 at 20:38
  • @Sigur you can't use size changes in math mode Commented Dec 19, 2014 at 20:38
  • @DavidCarlisle I am using a conference template. So What others details should I provide ?
    – Sai
    Commented Dec 19, 2014 at 20:43
  • @DavidCarlisle, sorry. My fault. I'll delete.
    – Sigur
    Commented Dec 19, 2014 at 20:48
  • Don't just list the packages, make a small example document, then you would notice the undefined command error when you run the above code. See my answer for an example. Commented Dec 19, 2014 at 20:50

2 Answers 2

3

If space constraints are really tight, you can reduce the size using smallmatrix, but it's better avoiding it as long as possible.

I have also introduced some changes to the input. Notably

  • \textbf has been changed into \mathbf;
  • flalign with \notag in all lines is align* (there's no point in using flalign anyway, in this case);
  • for the partial derivative, I used a personal command;
  • the brackets in the last equation has been turned into parentheses for avoiding confusion with matrices;
  • some vertical spacing has been added between equations

A line break in the second equation might be necessary anyway, but it depends on the line width in your document. The added vertical space could be removed if this line break doesn't reveal necessary.

\documentclass[twocolumn]{article}
\usepackage{amsmath,amssymb}
\usepackage{mathtools}

\newcommand{\pder}[2][]{%
  \frac{\partial#1}{\partial#2}%
}

\newenvironment{sbmatrix}
  {\left[\begin{smallmatrix}}
  {\end{smallmatrix}\right]}

\begin{document}

This is a paragraph on two lines that's supposed to
show the margins.
\begin{align*}
J_{G}(\textbf{x})
  &= \pder[G]{\mathbf{x}}
   = \pder{\mathbf{x}}(\mathbf{RP}_{i}+\mathbf{T}-\mathbf{Q}_{i})
\\[1ex]
J_{G}(\mathbf{x})
  &=\pder{\mathbf{x}}
    \left(
    \begin{sbmatrix}
    r_{11} & r_{12} & r_{13}\vphantom{P_{iy}}\\
    r_{21} & r_{22} & r_{23}\vphantom{P_{iy}}\\
    r_{31} & r_{32} & r_{33}\vphantom{P_{iy}}
    \end{sbmatrix}
    \begin{sbmatrix}
    P_{ix}\\
    P_{iy}\\
    P_{iz}
    \end{sbmatrix} +
    \begin{sbmatrix}
    x\vphantom{P_{iy}}\\
    y\vphantom{P_{iy}}\\
    z\vphantom{P_{iy}}
    \end{sbmatrix} -
    \begin{sbmatrix}
    Q_{ix}\\
    Q_{iy}\\
    Q_{iz}
    \end{sbmatrix}
    \right)
\\
  &=\begin{sbmatrix}
    1\vphantom{P_{iy}}\\
    0\vphantom{P_{iy}}\\ 
    0\vphantom{P_{iy}}
    \end{sbmatrix}
\\[1ex]
\pder[J_{i}]{\mathbf{x}} 
  &=2 \cdot
    \begin{bmatrix}
    1 & 0 & 0
    \end{bmatrix} \cdot
    \left(
    [\mathbf{RP}_{i}+\mathbf{T}]-
    \begin{sbmatrix}
    Q_{ix}\\ 
    Q_{iy}\\ 
    Q_{iz}
    \end{sbmatrix}
    \right)
\end{align*}

\end{document}

enter image description here

This is a version where the big right hand side is scaled down; note that I have scaled by the same amount the matrix in the third equation, for uniformity.

The result is not bad, but normal size should be preferred, whenever possible.

\documentclass[twocolumn]{article}
\usepackage{amsmath,amssymb}
\usepackage{mathtools}
\usepackage{graphicx}

\newcommand{\pder}[2][]{%
  \frac{\partial#1}{\partial#2}%
}

\newenvironment{sbmatrix}
  {\left[\begin{smallmatrix}}
  {\end{smallmatrix}\right]}

\begin{document}

This is a paragraph on two lines that's supposed to
show the margins.
\begin{align*}
J_{G}(\textbf{x})
  &= \pder[G]{\mathbf{x}}
   = \pder{\mathbf{x}}(\mathbf{RP}_{i}+\mathbf{T}-\mathbf{Q}_{i})
\\[1ex]
J_{G}(\mathbf{x})
  &=\pder{\mathbf{x}}
    \scalebox{.76}{$\displaystyle
    \left(
    \begin{bmatrix}
    r_{11} & r_{12} & r_{13}\\
    r_{21} & r_{22} & r_{23}\\
    r_{31} & r_{32} & r_{33}
    \end{bmatrix}
    \begin{bmatrix}
    P_{ix}\\
    P_{iy}\\
    P_{iz}
    \end{bmatrix} +
    \begin{bmatrix}
    x\\
    y\\
    z
    \end{bmatrix} -
    \begin{bmatrix}
    Q_{ix}\\
    Q_{iy}\\
    Q_{iz}
    \end{bmatrix}
    \right)
    $}
    =\scalebox{0.76}{$\displaystyle
    \begin{bmatrix}
    1\\
    0\\ 
    0
    \end{bmatrix}
    $}
\\[1ex]
\pder[J_{i}]{\mathbf{x}} 
  &=2 \cdot
    \begin{bmatrix}
    1 & 0 & 0
    \end{bmatrix} \cdot
    \left(
    (\mathbf{RP}_{i}+\mathbf{T})-
    \scalebox{0.76}{$\displaystyle
    \begin{bmatrix}
    Q_{ix}\\ 
    Q_{iy}\\ 
    Q_{iz}
    \end{bmatrix}
    $}
    \right)
\end{align*}

\end{document}

enter image description here

4
  • @Mico Not really: P_{iy} is slightly less high and slightly deeper than the mathstrut, so the brackets would turn out to be the same, but the entries will be misaligned.
    – egreg
    Commented Dec 19, 2014 at 21:21
  • @egreg Thank you so much for nice answer. Its almost close to what I needed. But I just would like to see how a scaled or resized version of second equation would look like. I am not able to figure out a proper command to do that.
    – Sai
    Commented Dec 19, 2014 at 21:22
  • sorry for pestering! Is it possible to just decrease the horizontal length ?
    – Sai
    Commented Dec 19, 2014 at 21:30
  • @Sai I added a version with scaling. The factor .76 has been computed by trial and error.
    – egreg
    Commented Dec 19, 2014 at 21:37
3

I would try to linebreak in preference to changing font size, perhaps:

enter image description here

\documentclass[a4paper,twocolumn]{article}
\raggedbottom
\usepackage{amsmath}

\begin{document}

\noindent X\dotfill X
\begin{flalign}
\notag J_{G}(\textbf{x}) &= \frac{\partial G}{\partial \textbf{x}} = \frac{\partial }{\partial \textbf{x}}(\mathbf{RP_{i}+T-Q_{i}})\\[\jot]
\notag J_{G}(\mathbf{x})&=
\begin{gathered}[t]
\frac{\partial }{\partial \mathbf{x}}\Biggl( \begin{bmatrix}
r_{11} & r_{12} & r_{13}\\ 
r_{21} & r_{22} & r_{23}\\ 
r_{31} & r_{32} & r_{33}
\end{bmatrix} \begin{bmatrix}
P_{ix}\\ 
P_{iy}\\ 
P_{iz}
\end{bmatrix}\\ + \begin{bmatrix}
x\\ 
y\\ 
z
\end{bmatrix} - \begin{bmatrix}
Q_{ix}\\ 
Q_{iy}\\ 
Q_{iz}
\end{bmatrix}\Biggr )\end{gathered}\\[\jot]
& = \begin{bmatrix}
1\\ 
0\\ 
0
\end{bmatrix}\\
\notag \frac{\partial J_{i}}{\partial \mathbf{x}} &= 2 \cdot \begin{bmatrix}
1 & 0 & 0
\end{bmatrix} \cdot \left [ \left [ \mathbf{RP_{i}+T} \right ]-\begin{bmatrix}
Q_{ix}\\ 
Q_{iy}\\ 
Q_{iz}
\end{bmatrix} \right ]
\end{flalign}
\noindent X\dotfill X


\vspace{\textheight}

\noindent X\dotfill X

\noindent X\dotfill X

\end{document}
9
  • thank you for the quick reply but could you please tell how can I resize to fit in a single line ?
    – Sai
    Commented Dec 19, 2014 at 20:55
  • 1
    @Sai You can't make that fit on a single line and be readable Commented Dec 19, 2014 at 20:57
  • I guess you could make the middle term fit on two rather than three lines.
    – Mico
    Commented Dec 19, 2014 at 20:58
  • Actually only a very small portion of it is crossing the border. Scaling of 0.9 should be enough. But I was not successful in using \scalebox or \resize options from other answers
    – Sai
    Commented Dec 19, 2014 at 20:59
  • 1
    @Sai on the column size I used it would need to be less than 50%, as I said in my initial comment if you don't say how wide the column is, people answering have to guess. Commented Dec 19, 2014 at 21:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .