7

How can I Tex this equation?

figure

I try to have exactly the same result but for the moment I only succeeded in having intersecting lines... Thanks!

  • 1
    Please show us the code you already have. Why make people type it for you and make the same 'errors' like you when trying to find some solution? – LaRiFaRi Apr 27 '15 at 14:18
6

You could use \midrule, a macro provided the booktabs package, inside an array environment. This setup will assure that the horizontal line will not intersect the vertical lines.

enter image description here

\documentclass{article}
\usepackage{booktabs}
\begin{document}
\[
M = 
\left( \begin{array}{c|c}
   A & B \\
   \midrule
   C & D \\
\end{array}\right)
\]
\end{document}

Addendum to address a follow-up question: If A has to be replaced with a 3x4 matrix, say, I suggest you do so by using a matrix environment (provided by the amsmath package) for the matrix, as is done in the following example.

enter image description here

\documentclass{article}
\usepackage{booktabs}  % for '\midrule' macro
\usepackage{amsmath}   % for 'matrix' environment
\begin{document}
\[
M = 
\left( \begin{array}{@{}c|c@{}}
   \begin{matrix}
      a & b & c & d \\
      e & f & g & h \\
      i & j & k & l 
   \end{matrix} 
      & B \\
   \cmidrule[0.4pt]{1-2}
   C & D \\
\end{array} \right)
\]
\end{document}
  • How to replace A, for instance, by a real matrix, a 3×4 matrix, say. @Mico – Hussein Eid Sep 24 '16 at 22:38
  • @HusseinEid - I've posted an addendum to address your question. – Mico Sep 24 '16 at 23:12
  • booktabs recommends that you never use vertical lines in a table. This suggests to me that while this may work at the moment, it may not work in a future version of the package. – Teepeemm Sep 25 '16 at 0:32
  • @Teepeemm - The booktabs package has been very stable since 2000. The updates since then have either just fixed bugs or added compatibility with packages such as longtable and colortbl. Do you have specific information regarding future changes to the booktabs package? – Mico Sep 25 '16 at 0:39
  • No information at all. But its author's denunciation of vertical lines makes me suspect that he hasn't even tried to test putting them into a table, and I wouldn't be surprised if vertical lines caused some sort of error down the road, either because of a slight change in booktabs, or because of a slightly different table that someone else is creating. – Teepeemm Sep 25 '16 at 1:06
3

A way of achieving this:

\documentclass{article}
\begin{document}
  \[
    M = \left(
    \begin{array}{c|c}
      A & B\\
      \hline
      C & D
    \end{array}
    \right)
  \]
\end{document}

enter image description here

  • I believe the OP does not want the horizontal and vertical lines to intersect. – Mico Apr 27 '15 at 14:04
  • @Mico I wonder, it is not very clear. Better that I had a go with this answer, it will be an occasion to clarify this. – Franck Pastor Apr 27 '15 at 14:07
2

Intercolumn space needs some adjustment but ...

\documentclass{article}
\begin{document}
  \[
    M = \left(\begin{array}{c@{}c@{}c}
      A & | & B\\
      \hline
      C & | & D
    \end{array}\right)
  \]
\end{document}

enter image description here

0

Try this:

$$ \left( \frac{A|B}{C|D} \right) $$

enter image description here

  • No, no , no, don't use $$....$$. It's 'outdated' and pure TeX. \[...\] is the better way. And it looks more like a block matrix than a pure fraction – user31729 Apr 27 '15 at 14:12
  • See the posting Why is [ … ] preferable to $$ … $$? for a discussion of why it's unwise to use $$ in a LaTeX document. – Mico Apr 27 '15 at 14:21

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.