2

I have a document where I enter a command \tab and that creates a table for me. The right part of the table always stays the same and the left part of the table is entered with arguments of the \tab function. I also need to enter between 1 and 6 images into this table in 2 separate rows and I created a separate function \tabgraph for this. This works fine altaugh I have to use a \begin{figure} and a \begin{minipage}, otherwise the pictures won't show and errors occur.

Problem #1: Depending on how much images I put in, the position of those images changes and they cover each other sometimes. See picture below:One pic is fine Two pics are not so fine, depending on their width Three pics are madness

Problem #2: I want the text in the last row to be on the left side of the picture, but I think since this Text is in a figure environment this creates problems.

Problem #3: \fbox should create a frame around the images, but the frame is only visible on one or two sides.

I also don't like to use the arraystretch{2} but I can't find a better solution.

So, my question: Is there a way to do this better?

Here is a MWE:

\documentclass[final]{article}
\usepackage[demo]{graphicx}
\usepackage[a4paper,left=25mm,right=25mm,top=2cm,bottom=2cm]{geometry}
\usepackage{caption}

\begin{document}

\newcommand{\tab}[5]
{% % % % % % % % % % % % % % % TABLE START% % % % % % % % % % % % % % % % %
    \begin{figure}[h!]
        \setlength\fboxsep{0pt}
        \setlength\fboxrule{.1mm}
        \renewcommand{\arraystretch}{2} 
        \tabcolsep5pt
        \begin{tabular}{|c|p{13cm}|}\hline
            \textbf{Row 1 Text text...} & #1 \\ \hline
            \textbf{Row 2 Text text...} & \hspace{\newline} #2 \\ \hline
            \textbf{Row 3 Text text...} & #3 \\ \hline
            \textbf{Row 4 Text text...} &  #4 \\ \hline
            \textbf{Row 5 Text text...} & #5 \\ \hline
        \end{tabular}
    \end{figure}
    % % % % % % % % % % % % % % % Table END% % % % % % % % % % % % % % % % %
}

\newcommand{\tabgraph}[1]
{
        \begin{minipage}{5cm}
        \centering
        \fbox{\includegraphics[height=5cm]{#1}}
        \caption{#1}
        \label{#1}
        \end{minipage}
}

\part{Part}
\section{Section}
\subsection{Title here}
\tab{Text Text Text Text Text Text Text}
    {\tabgraph{Fragezeichen}\tabgraph{Fragezeichen}\tabgraph{Fragezeichen}}
    {Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text}
    {Text Text Text Text Text Text Text}
    {\hspace{\newline} \tabgraph{Fragezeichen} \hspace{\newline\newline} Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text}
\end{document}

I solved my table. I use a \minipage for each image and put that into the table.

Here is the code:

\documentclass[final]{article}
\usepackage[demo]{graphicx}
\usepackage[a4paper,left=25mm,right=25mm,top=2cm,bottom=2cm]{geometry}
\usepackage{caption}

\begin{document}

    \newcommand{\tab}[5]{
        \centering
        \begin{tabular}{|c|p{11cm}|}
            \hline
            \textbf{Materials and Tools} & #1 \\
            \hline
            \textbf{Photo} & \vspace{0pt} #2 \\
            \hline
            \textbf{Steps} & #3 \\
            \hline
            \textbf{Process-parameters} &  #4 \\
            \hline
            \textbf{Check} & #5 \\
            \hline
        \end{tabular}
    }

    \newcommand{\tabgraph}[2]
    {
        \begin{minipage}{5cm}
            \centering
            \setlength\fboxsep{0pt}
            \setlength\fboxrule{.2mm}
            \fbox{\includegraphics[height=4.4cm]{#1}}
            \captionof{figure}{#2}
        \end{minipage}
    }

    \tab{Received the likewise law graceful his. Nor might set along charm now equal green. Pleased yet equally correct colonel not one.}
    {\tabgraph{sasda}{capt} \tabgraph{asdfasdf}{capt}}
    {Received the likewise law graceful his. Nor might set along charm now equal green. Pleased yet equally correct colonel not one. Say anxious carried compact conduct sex general nay certain.}
    {Received the likewise law graceful his. Nor might set along charm now equal green. Pleased yet equally correct colonel not one.}
    {\vspace{0pt} \tabgraph{sdaf}{capt} \newline Received the likewise law graceful his. Nor might set along charm now equal green. Pleased yet equally correct colonel not one.}

\end{document}

No more warnings or errors. I just can't align the text in the left column into the middle (horizontally). Any ideas? Also the spacing between the rows is too little.

Sputnik
  • 31
  • 2
    Just a suggestion: if I were you, I would specify the original use-case you're trying to solve using this tabular-minipage-figure combination. Perhaps you could receive a better solution for the original problem. (see XY-problem) – masu Jul 14 '14 at 14:01
  • And your MWE is not an MWE. You should replace \usepackage{graphicx} with \usepackage[demo]{graphicx} at least to remove "file not found" errors (due to images missing). But your example is still not compilable for me... – masu Jul 14 '14 at 14:06
  • OK thanks, I didn't know about the [demo] command. It compiles on my PC. I use TexStudio. But I see the warnings and errors (Bad box, Missing number, Illegal unit of measure (pt inserted)). I have been looking around for days how to solve these. – Sputnik Jul 14 '14 at 14:11
  • 1
    Your MWE is still bad... 1. What is \hspace{\newline} supposed to mean?! \vspace{\baselineskip}? 2. labeling with the same label... \label{#1} is unnecessary and bogous in your example... 3. Don't use the figure environment (imho) if you don't want a "floating box" figure. 4. You should read this topic on ending lines with the % symbol. – masu Jul 14 '14 at 14:32
  • The multiple labels is also a little bit annoying ;-) –  Jul 14 '14 at 14:36
  • 2
    The missing left and top frame parts of \fbox is a pdf viewer issue –  Jul 14 '14 at 14:45
  • I have solved my table. – Sputnik Jul 18 '14 at 07:03
  • 1
    For the final entry, placing text on the left of the picture can be achieved with a minipage: {\begin{minipage}{5cm}Received\dots\end{minipage} \tabgraph{sdaf}{capt}} – Andrew Swann Jul 18 '14 at 08:04

0 Answers0