2

I'm very new to Latex and am trying to write in a solution to total matrix. I have used this:

\end{array}\right)$$=$$\left(\begin{array}{cccc|c}  
1 & 0 & 0 & -\frac{1}{2}t & 0\\  
0 & 0 & 0 & -\frac{1}{4}t & 0\\
0 & 0 & 1 & \frac{1}{4}t & 0\\ 
0 & 0 & 0 & 0 & 0 
\end{array}\right)$\\\\

\end{array}\right)$$=$$\left(\begin{array}{cccc|c}  
1 & 0 & 0 & -\frac{1}{2}t & 0\\  
0 & 0 & 0 & -\frac{1}{4}t & 0\\
0 & 0 & 1 & 28978 & 0\\ 
0 & 0 & 0 & 0 & 0 
\end{array}\right)$\\\\

The problem is that I have a whole bunch of these and some of the are wider than others, which does not look very nice.

Is there any way to declare a certain size for all of the arrays that I have made?

  • why do you have $$=$$ in the middle and not = ? – David Carlisle Nov 24 '17 at 21:41
  • Mistake, sorry. – bub Nov 24 '17 at 21:47
  • 3
    please always post a complete small document, you are asking how to make some arrays the same width (I assume you mean make the columns the same width, you presumably don't want a 1-column array to be as wide as a 5 column one? but it is hard to guess the context with just a fragment that doesn't even have two complete arrays. Also what is the `\\\` at the end? – David Carlisle Nov 24 '17 at 21:52
  • 2
    ... @bub below your question you coud find the "edit button". To correct your little = mistake and to add compilable code, starting with \documentclass and ending with \end{document}. – Bobyandbob Nov 24 '17 at 21:58
2

(revised this answer completely after receiving further information from the OP)

I'm not sure if I understand that nature of your array environments. It seems they all have five columns, and that the fourth column can have entries of widely varying widths. Suppose, furthermore, that the single widest entry in any of the arrays' fourth columns is the number "28978". If that's the case, it suffices to exchange the variable-widtyh c column type with a fixed-width column type, as is done in the code shown below.

enter image description here

\documentclass{article}
\newlength\mylen
\settowidth{\mylen}{$28978$} % calculate width of widest element
\usepackage{array} % for "\newcolumntype" macro
\newcolumntype{Q}{>{\centering$}p{\mylen}<{$}}

\begin{document}
\renewcommand\arraystretch{1.33}
\[
\left(\begin{array}{cccQ|c}  
1 & 0 & 0 & -\frac{1}{2}t & 0\\  
0 & 0 & 0 & -\frac{1}{4}t & 0\\
0 & 0 & 1 & \frac{1}{4}t & 0\\ 
0 & 0 & 0 & 0 & 0 
\end{array}\right)
\]

\[
\left(\begin{array}{cccQ|c}  
1 & 0 & 0 & -\frac{1}{2}t & 0\\  
0 & 0 & 0 & -\frac{1}{4}t & 0\\
0 & 0 & 1 & 28978 & 0\\ 
0 & 0 & 0 & 0 & 0 
\end{array}\right)
\]
\end{document}
  • Sorry but that's not what I am looking for. Say that I have to arrays and want them the same width, then what? I've updated the description. – bub Nov 25 '17 at 16:15
  • @bub - I've updated my answer. Is the new solution close to what you are looking to achieve? – Mico Nov 25 '17 at 20:28
  • Is it possible to do also for |c? – bub Nov 25 '17 at 23:57
  • @bub - Yes. (Aside: If you have a specific case in mind, please provide more details. This site is not all that well-suited for general, vague conversations. It works much better to solve specific, detailed cases.) – Mico Nov 26 '17 at 6:30
1

You can use tabularx to fix the total width

\begin{tabularx}{8cm}{|l|X|l|X|}  
\hline A&B&C&D\\  
\hline  
\end{tabularx}

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.