4

For some reason, when I put the period, \hspace doesn't do anything (unless it's big enough)

Code:

%\documentclass[12 pt,handout,notheorems]{beamer}
\documentclass[12 pt,handout,notheorems, serif]{beamer}
%\documentclass[12 pt]{article}
\usepackage{pgfpages}
\pgfpagesuselayout{resize to}[a4paper,landscape]
\usetheme{Boadilla}
\usefonttheme{professionalfonts} %To get the accents aligned correctly, albeit in Computer Modern Roman
\usepackage{cancel}
\usepackage{amsmath}
\usepackage{bm}
\begin{document}
    \begin{equation}
        \hspace{-0.21cm}
        \left[\cancelto{\mathbf{0}}{\frac{\partial\phi}{\partial\mathbf{x}}} - \bm{\lambda}\right]^{\textrm{T}}_{*,t_f}\delta\mathbf{x}_f + \cancelto{0}{\left[\frac{\partial\phi}{\partial t} + \mathcal{H}\right]_*}\delta t_f = 0 \rightarrow \lambda_1^*\left(t_f\right) = \lambda_2^*\left(t_f\right) = 0. %Period
    \end{equation}
    \begin{equation}
        \hspace{-0.21cm}
        \left[\cancelto{\mathbf{0}}{\frac{\partial\phi}{\partial\mathbf{x}}} - \bm{\lambda}\right]^{\textrm{T}}_{*,t_f}\delta\mathbf{x}_f + \cancelto{0}{\left[\frac{\partial\phi}{\partial t} + \mathcal{H}\right]_*}\delta t_f = 0 \rightarrow \lambda_1^*\left(t_f\right) = \lambda_2^*\left(t_f\right) = 0 %No period
    \end{equation}
\end{document}

Output: enter image description here

Is there a way to make sure that \hspace actually does its job without the period interfering it?

2
  • 3
    I tried this on my updated TeXLive 2020 installation. There I am unable to reproduce the behavior with pdflatex, but it is there with lualatex and XeLaTeX. In addition I get the funny error message under lualatex : Class beamer Warning: ``serif'' is obsolete. Use font theme ``serif'' instead on input line 336.. So +1 for entertainment. ;-)
    – user194703
    May 7, 2020 at 7:16
  • Oh yeah, I forgot to say I am using lualatex on TeXstudio.
    – Superman
    May 7, 2020 at 7:17

1 Answer 1

3

The trick is explained in the TeXbook. It needs a glob of glue at the beginning of the equation (not negative, unless you want to go in the margin) and a strange glue specification at the end

\hspace{1000pt minus 1fill}

which will trick TeX into thinking that it has a very very long equation, so it will try to accommodate it by squeezing it into the line. At typesetting time, the large shrinkability makes for normal spacing.

I also changed the \left-\right pairs into \Biggl-\Biggr, so the first brackets are not humongous and the second ones match the height. However, I think that \biggl-\biggr is the proper size, as shown in the second equation.

\documentclass[12 pt,handout,notheorems, serif]{beamer}
%\documentclass[12 pt]{article}
\usepackage{pgfpages}
\pgfpagesuselayout{resize to}[a4paper,landscape]
\usetheme{Boadilla}
\usefonttheme{professionalfonts} %To get the accents aligned correctly, albeit in Computer Modern Roman
\usepackage{cancel}
\usepackage{amsmath}
\usepackage{bm}

\begin{document}

\begin{equation}
\hspace{0pt}
\Biggl[
  \cancelto{\mathbf{0}}{\frac{\partial\phi}{\partial\mathbf{x}}} - \bm{\lambda}
\Biggr]^{\mathrm{T}}_{*,t_f}\delta\mathbf{x}_f
+ \cancelto{0}{\Biggl[\frac{\partial\phi}{\partial t} + \mathcal{H}\Biggr]_*}\delta t_f
= 0 \rightarrow \lambda_1^*\left(t_f\right) = \lambda_2^*\left(t_f\right) = 0.
\hspace{1000pt minus 1fill}
\end{equation}

\begin{equation}
\hspace{0pt}
\biggl[
  \cancelto{\mathbf{0}}{\frac{\partial\phi}{\partial\mathbf{x}}} - \bm{\lambda}
\biggr]^{\mathrm{T}}_{*,t_f}\delta\mathbf{x}_f
+ \cancelto{0}{\biggl[\frac{\partial\phi}{\partial t} + \mathcal{H}\biggr]_*}\delta t_f
= 0 \rightarrow \lambda_1^*\left(t_f\right) = \lambda_2^*\left(t_f\right) = 0.
\hspace{1000pt minus 1fill}
\end{equation}

\end{document}

enter image description here

1
  • Looks like a good solution! Thank you, will look into it!
    – Superman
    May 7, 2020 at 8:13

You must log in to answer this question.

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