How do I fix this generated LaTex code for a matrix?

In summary, the conversation discusses a problem with the generated code from Scientific Workplace for a matrix in LaTex. The code contains non-standard macros and the individual seeks advice on how to fix it without making major changes. They are provided with a helpful link and two alternative ways of formatting the matrix in a more standard way.
  • #1
PainterGuy
940
69
Hi,

I'm using Scientific Workplace to write LaTex and it generates the code shown below for the given matrix. I don't think the generated code is standard LaTex in this particular instance. How can I fix it without making too many modifications? I mean if there is a simple way to fix it. Thank you for your help, in advance!

1618472829295.png


Generated code:
$M_{1}=\left[ \MATRIX{2,2}{c}\VR{,,c,,,}{,,c,,,}{,,,,,}\HR{,,}\CELL{3.0}\CELL{914.\,\allowbreak 5}\CELL{1434.\,\allowbreak 5}\CELL{4.\,\allowbreak 151\,4\times 10^{5}}\right] $

Trying to compile the generated code:
[tex]M_{1}=\left[ \MATRIX{2,2}{c}\VR{,,c,,,}{,,c,,,}{,,,,,}\HR{,,}\CELL{3.0}\CELL{914.\,\allowbreak 5}\CELL{1434.\,\allowbreak 5}\CELL{4.\,\allowbreak 151\,4\times 10^{5}}\right][/tex]Helpful link:
https://www.physicsforums.com/threads/introducing-latex-math-typesetting.8997/
 
Last edited:
Physics news on Phys.org
  • #2
Yes, it looks like it uses non-standard macros. Probably there is a style or class file somewhere (look for extensions .sty or .cls) that you can load into your ##\LaTeX##-document to ensure these macros work. If you want to use the generated code, it may be best to look into that.

Alternatively, a more standard way of formatting would be
$$
\begin{bmatrix}
3.0& 914.5\\
1434.5& 4.1514 \times 10^5
\end{bmatrix}
$$
To see the code, right click on the above expression, then Show Math As - TeX Commands. If you insist on including the table bars, you could try something like
$$
\left[
\begin{array}{|c|c|}
\hline
3.0& 914.5\\
\hline
1434.5& 4.1514 \times 10^5\\
\hline
\end{array}
\right]
$$
 
Last edited:
  • Like
Likes PainterGuy and FactChecker

1. How do I fix missing parentheses or brackets in my matrix code?

The most common reason for missing parentheses or brackets in a matrix code is that the code is not properly nested. Make sure that each opening bracket is paired with a closing bracket, and that all brackets are in the correct order. You may also want to check if any brackets were accidentally omitted or if there are any extra brackets that are not necessary.

2. Why is my matrix not displaying correctly?

There are several reasons why a matrix may not be displaying correctly in LaTex. First, check if the matrix code is surrounded by the necessary \begin{matrix} and \end{matrix} commands. Also, make sure that the matrix is properly aligned with the & symbol, and that the correct number of columns and rows are specified. Additionally, check if there are any typos or missing commands in the matrix code.

3. How do I fix spacing issues in my matrix?

If your matrix is displaying with uneven spacing or overlapping elements, you may need to adjust the spacing commands in your code. Try adding \hspace or \vspace commands to create more space between elements. You can also adjust the size of the matrix using \resizebox or \scalebox commands.

4. Why is my matrix code generating errors?

There are a few common errors that can occur when generating LaTex code for a matrix. These include missing or misplaced commands, incorrect syntax, and unrecognized symbols. Make sure to carefully review your code for any mistakes or typos, and consult LaTex documentation for proper syntax and commands.

5. How can I add labels or captions to my matrix?

To add labels or captions to your matrix, you can use the \label and \caption commands. Place the \label command after the \end{matrix} command, and then use the \caption command to add a description or title for your matrix. You can also use the \subcaption command to add labels or captions to individual rows or columns within the matrix.

Similar threads

  • Nuclear Engineering
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
274
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
3K
Replies
0
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
15
Views
25K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
7K
Replies
7
Views
2K
  • Programming and Computer Science
Replies
5
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Programming and Computer Science
2
Replies
54
Views
4K
Back
Top