1

Once I seem to have worked on a system where, for some reason, latex code containing

     $\array{a & b \\ c & d }$

seems to have worked. (Note that, in particular, the "alignment" options of the {rcrcr} kind, standard in the usual \begin{align} \end{align} construction, is missing here. Now I need to compile this on what is a more or less standard latex installation, and it does not compile as is. Of course, one option would be to edit everything into the standard \begin{align} \end{align}.

Question: can you recommend an alternative, so as to be able to compile such code with as little editing overhead as possible? Some package or option in the preamble?

1

If you don't want to change the syntax at all, just [re]define \array, but I would not do that, as array is a widely used beginning to the array environment of LaTeX. I would rename it as \myarray, which can be defined to be an aligned TABstack.

\documentclass[12pt]{article}
\usepackage{tabstackengine}
\newcommand\myarray{\alignCenterstack}
\TABstackMath
\setstackgap{L}{1.2\normalbaselineskip}% inter-row baselineskip
\setstackaligngap{1em}% horizontal gap between align groups
\begin{document}
$\myarray{a =& b \\ c =& d }$\quad
$\myarray{y =& mx + b \\ E =& mc^2 }$ or this
$\myarray{a =& b & y =& mx + b\\ c =& d& E =& mc^2 }$
\end{document}

enter image description here

  • Useful solution, thank you. I marked it as answered since the portions of my "legacy" code I had been testing so far worked with your method. Now (working incrementally) I reached a place where I used the \overset{}{} command, and suddenly there are error messages, in particular "Missing control sequence inserted. <inserted text> \inaccessible". Do you know a solution to this, from these information alone? (I know that one possibly should isolate the problem and post a minimal non-working example, but I am checking first whether there is a quick "the reason must be this or that" solution.) – Peter Heinig Jun 30 '17 at 15:14
  • @PeterHeinig I would have to see some code, though mabe all you need is to include the amsmath package. Unfortunately, I am going offline for a few days, starting NOW! – Steven B. Segletes Jun 30 '17 at 15:46
0

As @egreg has already pointed out in a comment, you may be thinking of the \matrix command. For sure, the following code, which sets up a macro called \myarray, compiles properly.

enter image description here

\documentclass{article}
\usepackage{amsmath} % for 'matrix' environment
\newcommand\myarray[1]{\begin{matrix}#1\end{matrix}}
\begin{document}
$\myarray{a & b \\ c & d }$
\end{document}

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.