2

I would like to create a pdf as the image shows. In black regions, I have one or multiple images, while in red box region I have rotated text for describing rows in this region (In this picture I have three regions, in the last region I have one or two rows). It will be very nice I can draw a line for separating these regions.

enter image description here

Edit: I want captions on these pictures as well. Originally I've created the table with matlab, but I want to use LaTeX now: row labels turned 90 degrees in red, each row filled with small pictures, where each has a caption consisting of two numbers in blue, with lines separating the rows. And I also want to make use of the full page. It would be better if I could edit the horizontal padding between images and vertical alignment of these images.

4
  • Use a tabular environment to arrange the images and texts in a grid-like fashion and to add separating lines.

  • Use the booktabs package to get a better table layout and nicer lines.

  • Use the rotating package to get the sideways environment that will turn its contents 90 degrees counterclockwise.

  • Use the array package to save typing: It allows you to use the notation >{...} and <{...} to add material in every cell of the column.

  • In a tabular entry, you can use further tabulars.

enter image description here

\documentclass{article}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{array}
\newcommand\pic[2][1cm]{\includegraphics[height=#1]{example-image-#2}}
\begin{document}
\begin{tabular}{>{\begin{sideways}}l<{\end{sideways}}l}
\toprule
  image A
& \pic[2cm]{a}
\\\midrule
  5 images B
& \pic[2cm]{b}\pic[2cm]{b}\pic[2cm]{b}\pic[2cm]{b}\pic[2cm]{b}
\\\midrule
  \begin{minipage}{3cm}
  Many more images C arranged as a grid,
  and a longer text.
  \end{minipage}
& \begin{tabular}[b]{@{}ccccc@{}}
    \pic{c} & \pic{c} & \pic{c} & \pic{c} & \pic{c} \\
    \pic{c} & \pic{c} & \pic{c} & \pic{c} & \pic{c} \\
    \pic{c} & \pic{c} & \pic{c} & \pic{c} & \pic{c}
  \end{tabular}
\\\bottomrule
\end{tabular}
\end{document}

Edit: Here is another example that takes into account further requirements specified in an edit of the original post.

  • For the table to occupy the whole \textwidth without having to calculate the available space ourselves we use a tabularx environment with an X column. Moreover, to center the contents of the cells vertically, we redefine the X column type.

    \usepackage{tabularx}
    \renewcommand\tabularxcolumn[1]{m{#1}}
    ...
    \begin{tabularx}{\textwidth}{m{2ex}}X}
    
  • We want the first column rotated and in red, so we replace m{2ex} by

    >{\begin{sideways}\color{red}}m{2ex}<{\end{sideways}}
    

    which inserts the necessary commands at the beginning and end of each cell.

  • The elements of the second column are supposed to be structured items themselves consisting of a caption with two values and an image. So we define a command

    \captpic{A-value}{B-value}{name of image}
    

    as follows (modify as needed).

    \newcommand\pic[1]{\includegraphics[width=1cm]{#1}}
    \newcommand\captpic[3]%
      {\begin{tabular}[t]{@{}c@{}}
         \footnotesize\color{blue} A: #1\\[-1ex]
         \footnotesize\color{blue} B: #2\\
         \pic{#3}
       \end{tabular}%
      }
    

enter image description here

\documentclass{article}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{tabularx}
\renewcommand\tabularxcolumn[1]{m{#1}}
\usepackage{xcolor}
\newcommand\pic[1]{\includegraphics[width=1cm]{#1}}
\newcommand\captpic[3]%
  {\begin{tabular}[t]{@{}c@{}}
     \footnotesize\color{blue} A: #1\\[-1ex]
     \footnotesize\color{blue} B: #2\\
     \pic{#3}
   \end{tabular}%
  }
\begin{document}
\noindent
\begin{tabularx}{\textwidth}%
  {>{\begin{sideways}\color{red}}m{2ex}<{\end{sideways}}%
   X%
  }
\toprule
  sample
& \pic{example-image-a}
\\\midrule
  selection 1
& \captpic{1}{0.00}{example-image-b}
  \captpic{2}{0.01}{example-image-b}
  \captpic{3}{0.02}{example-image-b}
  \captpic{4}{0.03}{example-image-b}
  \captpic{5}{0.04}{example-image-b}
  \captpic{6}{0.05}{example-image-b}
  \captpic{7}{0.06}{example-image-b}
  \captpic{8}{0.07}{example-image-b}
  \captpic{9}{0.08}{example-image-b}
  \captpic{10}{0.09}{example-image-b}
\\\midrule
  selection 2
& \captpic{1}{0.00}{example-image-b}
  \captpic{2}{0.01}{example-image-b}
  \captpic{3}{0.02}{example-image-b}
  \captpic{4}{0.03}{example-image-b}
  \captpic{5}{0.04}{example-image-b}
  \captpic{6}{0.05}{example-image-b}
  \captpic{7}{0.06}{example-image-b}
  \captpic{8}{0.07}{example-image-b}
  \captpic{9}{0.08}{example-image-b}
  \captpic{10}{0.09}{example-image-b}
  \captpic{11}{0.10}{example-image-b}
  \captpic{12}{0.11}{example-image-b}
  \captpic{13}{0.12}{example-image-b}
  \captpic{14}{0.13}{example-image-b}
\\\bottomrule
\end{tabularx}
\end{document}
  • in second row i want multiple images for example like 10. How can I do that? – neouyghur Jan 7 '17 at 16:47
  • @neouyghur I've edited my answer. The example now shows possibilities to have several images: Put them one after the other if you want them side by side from left to right, or use another sub-tabular to arrange the images in two dimensions. – gernot says Reinstate Monica Jan 7 '17 at 17:14
  • thank you. But I want captions on these picture as well. Could you check this dropbox.com/s/rsl4ao2nvzjsazy/1_1_10.pdf?dl=0, which is created by matlab, but I want latex version now. And I also want to make use of the full page. – neouyghur Jan 7 '17 at 17:46
  • 1
    @neouyghur See the edit of my answer. Please: If you have further questions, don't ask them in the comments but ask a new question, giving the code that you have so far. Moreover: Don't link to external resources since soon they will be no longer available and the question will become unclear. I've added the image to your original post; hope this is ok regarding copyrights. – gernot says Reinstate Monica Jan 7 '17 at 19:07
  • @neouyghur Ok, I've seen your edit to my post as well as your post. I will remove the specifics of your application. – gernot says Reinstate Monica Jan 8 '17 at 17:04

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.