3

I use the following code when I want to typeset math which was kindly written by Stephen B. Segletes but I have a problem when I try to use in it the cases environment. There is no problem with the cases code as when I use it outside the \SS it works. Why is that happenning? How can I fix it?

\documentclass[12pt]{article}
\usepackage[top=0.3in, bottom=1.2in, left=0.8in, right=0.8in]{geometry}

\usepackage{multicol}

\setlength{\parindent}{0cm}

\usepackage{xltxtra}
\usepackage{xgreek}
\setmainfont[Mapping=tex-text]{GFSDidot.otf}
\setsansfont[Mapping=tex-text]{GFSDidot.otf}

\usepackage{amsmath}
\usepackage{unicode-math}

\everymath{\displaystyle}



\usepackage[usestackEOL]{stackengine}
\stackMath
\def\stackalignment{l}
\setstackgap{S}{10pt}
\def\SS#1{\noindent\addstackgap[3pt]{\Shortstack{#1}}\vspace{2ex}\par\vfil}


\newcommand{\3}{\vspace{0.3cm}}

\title{}
\author{}
\date{}

\begin{document}

\SS{
\vec{H}_{1}=\vec{H}_{3}=0\Rightarrow \vec{B}_{1}=\vec{B}_{3}=0\\
\vec{H}_{2}=K_{0}\hat{x}\\
\vec{B}_{2}=\begin{cases}
\mu_{1}(z)\vec{H}=\mu_{1}(z)K_{0}\hat{x} & 0<z<h_{1}\\
\mu_{2}H=\mu_{2}K_{0}\hat{x} & h_{1}<z<h
\end{cases}
}

\end{document}
  • 1
    the stackengine approach to formatting multiple lines of math is quite different from that of amsmath, where cases is defined. although i haven't tried to combine them, the philosophy is so different that i haven't much confidence that they would be compatible. – barbara beeton Apr 27 '14 at 19:20
  • could you link to the question/answer where you got the code? – cmhughes Apr 27 '14 at 19:25
  • I don't know how to do that. – Adam Apr 27 '14 at 19:52
  • @barbarabeeton what do you mean? By multiple lines of code you mean the cases environment or the whole approach with the stackengine?Don't you think that it is a good way to write multiple lines of code? – Adam Apr 27 '14 at 19:56
  • @Adam -- stackengine addresses only the presentation (visual) aspect of the material; amsmath tries to take into consideration the "meaning" (as it might be interpreted by someone who is visually impaired and requires an audio presentation). it's roughly equivalent to "presentation mathml" vs. "content mathml". i'd rather not try to address whether one is "better" than the other, but since the structure of the two is significantly different, how to make them work together seamlessly isn't obvious, and probably not trivial. – barbara beeton Apr 28 '14 at 0:32
3

Just add braces around cases. However, I can't understand what's the purpose of using another package. Here's an example, where I removed all the unnecessary things (and also the final \vfil). I renamed your personal command, because it's a very bad idea to redefine \SS.

\documentclass[12pt]{article}
\usepackage{amsmath}

\usepackage[usestackEOL]{stackengine}
\stackMath
\def\stackalignment{l}
\setstackgap{S}{10pt}
\newcommand\AdamSS[1]{\noindent\addstackgap[3pt]{\Shortstack{#1}}\vspace{2ex}\par}%\vfil}

\begin{document}

\AdamSS{
\vec{H}_{1}=\vec{H}_{3}=0\Rightarrow \vec{B}_{1}=\vec{B}_{3}=0\\
\vec{H}_{2}=K_{0}\hat{x}\\
\vec{B}_{2}={\begin{cases}
\mu_{1}(z)\vec{H}=\mu_{1}(z)K_{0}\hat{x} & 0<z<h_{1}\\
\mu_{2}H=\mu_{2}K_{0}\hat{x} & h_{1}<z<h
\end{cases}}
}

\noindent$\!\begin{aligned}
\vec{H}_{1}&=\vec{H}_{3}=0\Rightarrow \vec{B}_{1}=\vec{B}_{3}=0\\
\vec{H}_{2}&=K_{0}\hat{x}\\
\vec{B}_{2}&=
  \begin{cases}
  \mu_{1}(z)\vec{H}=\mu_{1}(z)K_{0}\hat{x} & 0<z<h_{1}\\
  \mu_{2}H=\mu_{2}K_{0}\hat{x} & h_{1}<z<h
  \end{cases}
\end{aligned}$

\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.