How to draw something like below in latex:

enter image description here

  • 1
    Welcome to TeX.SX! On this site, a question should typically revolve around an abstract issue (e.g. "How do I get a double horizontal line in a table?") rather than a concrete application (e.g. "How do I make this table?"). Questions that look like "Please do this complicated thing for me" tend to get closed because they are either "off topic", "too broad", or "unclear". Please try to make your question clear and simple by giving a minimal working example (MWE): you'll stand a greater chance of getting help. – user31729 Aug 5 '15 at 11:01
  • Very much related: tex.stackexchange.com/questions/168035/… – Steven B. Segletes Aug 5 '15 at 11:04

Here is a first cut, based on my answer at Matrix decomposition dimensions diagram.

Syntax for a box is \matbox{rows}{row-label}{columns}{column-label}{box-title}. For example, \matbox{3}{dimensions}{8}{documents}{...} creates a box of 3 rows labeled "dimensions" and 8 columns labeled "documents".

To allow for the complex box title, I introduce \titlebox[width]{primary-math-label}{sub-text}. Boxes may be vertically shifted with \raiserows{row-shift}{box-to-be-shifted}. The row-shift should be set to 1/2 the difference of the row height of the matrices. For example, here the tall matrices are 7 rows, the small are 3 rows high. Thus the shift is .5(7-3) = 2.

\newcommand\titlebox[3][30ex]{\stackanchor{#2}{\scalebox{.45}{\parbox{#1}{\centering #3}}}}
  \titlebox[20ex]{X}{transformed word-document co-occurance matrix}} 
\matbox{7}{words}{3}{dimensions}{\titlebox[10ex]{U}{word space}} 
  \raiserows{2}{\matbox{3}{dimensions}{8}{documents}{\titlebox{V^T}{document space}}}%

enter image description here

With the default \matscale=1, one row will occupy a height of 1\baselineskip. Thus, the box sizes may be globally changed by resetting \matscale. In the above MWE, I reset the value to .6, so that 7 rows occupies .6(7) = 4.2\baselineskip of vertical distance. The numbers of rows and columns can be set to actual matrix values, which can be very large, as long as the \matscale is appropriately reduced in tandem with the size of the row/column values.

Below is the appearance when \matscale is changed to 0.8:

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.