1

I needed a word between a couple of aligned equations but the space between the word and the next equation is too big. Is there a quick adjustment for this one part of of my document? (note: using {alignat*} environment so I don't have to keep telling LaTeX I don't want numbers)

(Code fixed)

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[]{amsthm} 
\usepackage[]{amssymb} 
\usepackage[]{amsmath}
\usepackage{textcomp}
\usepackage{chngcntr}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{wrapfig}
\usepackage{physics}
\usepackage{mathtools}
\usepackage{bm}


\usepackage{listings}
\usepackage{xcolor}
\usepackage[T1]{fontenc}
\usepackage[numbered]{matlab-prettifier}


\lstset{frame=tb,
  language=Java,
  aboveskip=3mm,
  belowskip=3mm,
  showstringspaces=false,
  columns=flexible,
  basicstyle={\small\ttfamily},
  numberstyle=\tiny\color{gray},
  keywordstyle=\color{blue},
  commentstyle=\color{dkgreen},
  stringstyle=\color{mauve},
  breaklines=true,
  breakatwhitespace=true,
  tabsize=3}
\begin{document}
\begin{align*}
(a-\lambda)v_1 + b v_2 &= 0,\\
cv_1 + (a-\lambda)v_2 + b v_3 &= 0\\
\cdots\quad\qquad&\\
cv_{n-3} + (a-\lambda)v_{n-2} + b v_{n-1} &= 0
\intertext{and}
cv_{n-1} + (a-\lambda)v_{n} &= 0.
\end{align*}
\end{document}

That space after 'and', possibly before too, is too big, I think

3
  • please provide complete small document beginning with \documentclass{...} used packages relevant to your problem and ended with \end{document} . help us to help you. on the first sight your code is unusual and doesn't work.
    – Zarko
    Mar 6, 2018 at 4:19
  • Good point. I have to truncate because the doc is 10 pages long with images. one second...
    – user391838
    Mar 6, 2018 at 4:33
  • I fixed the matlab code, I put \begin{document} at the beginning of preamble, sorry. I do not know what packages are not being used but they are all used for something elsewhere and need to remain. I used your example but the page looks the same...
    – user391838
    Mar 6, 2018 at 4:50

2 Answers 2

4

enter image description here

(red lines indicate text borders)

minimal working example:

\documentclass{article}
\usepackage{mathtools}% instead of amsmath, it provide \shortintertext

\begin{document}
    \begin{align*}
(a-\lambda)v_1 + b v_2                       & = 0,  \\% removed \left( and \right)
cv_1 + (a-\lambda)v_2 + b v_3                & = 0   \\% removed \left( and \right)
\cdots\quad\qquad                            &       \\% removed \left( and \right)
cv_{n-3} + (a-\lambda)v_{n-2} + b v_{n-1}    & = 0   % removed \left( , \right) and \\
\shortintertext{and}
cv_{n-1} + (a-\lambda)v_{n}                  & = 0.  % removed \left( , \right) and \\
    \end{align*}
\end{document}

your document has errors. please try to compile it. for showing your problem the most of preamble is not relevant.

4
  • Did you just take off the two \\? I am assuming that's the solution...(?)
    – user391838
    Mar 6, 2018 at 4:42
  • see edited answer. too code i added comments with short record of changes in comparison to your code. i completely changed your code.
    – Zarko
    Mar 6, 2018 at 4:46
  • oh, I see the ammendments now. Let me try again. Thanks.
    – user391838
    Mar 6, 2018 at 4:51
  • "\shortintertext" was the solution. Thank you for showing me the solution as well as how to clean up my alignment. I also learned that I had an erroneous assumption about the align environment, as I can suppress numbering after all
    – user391838
    Mar 6, 2018 at 4:57
3

Another possibility is nccmath (whch also loads amsmath); it gives full control on the spacing of \intertext with an optional argument:

\documentclass{article}
\usepackage{mathtools}% instead of amsmath, it provide \shortintertext
\usepackage{nccmath} % proviides medium sized formulae and acontrol of intertext soacing via an optional argument

\begin{document}

    \begin{align*}
        (a-\lambda)v_1 + b v_2 & = 0, \\% removed \left( and \right)
        cv_1 + (a-\lambda)v_2 + b v_3 & = 0 \\% removed \left( and \right)
        \cdots\quad\qquad & \\% removed \left( and \right)
        cv_{n-3} + (a-\lambda)v_{n-2} + b v_{n-1} & = 0 % removed \left( , \right) and \\
        \intertext[-1ex]{and}
        cv_{n-1} + (a-\lambda)v_{n} & = 0. % removed \left( , \right) and \\
    \end{align*}

\end{document} 

enter image description here

You must log in to answer this question.

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