3

This is my actual coding.It's a long table. I would like to add the figure caption to "nyquistplot' figure in this long table environment.

I tried to use captionof but still unable to make it.

And Also I would like to move the "Not stable" to top of that column.

\documentclass[review,12pt]{elsarticle}
\usepackage{graphicx}
\usepackage[table]{xcolor}
\usepackage{longtable}
\usepackage{pbox} %for the width of table column

\begin{document}


\begin{center}
\begin{longtable}[ht]{|>{\centering\arraybackslash} p{1.8cm}|>{\raggedright\arraybackslash} p{3cm}|>{\raggedright\arraybackslash} p{4cm}|>{\raggedright\arraybackslash} p{4cm}|}%>{\raggedright\arraybackslash} p{5cm}|}
\caption{Stability of PID controller for case 1 based on theorem 1}
\label{tab:stabilitync1}

\\

\hline
\multicolumn{4}{|c|}{\centering case 1: $q_1<0$ and $q_2<0$}      \\ \hline
Sub-cases & $K$ & $\tau_I$ & $\tau_D$ \\ \hline %& Stability (necessary criterion) \\ \hline
\endfirsthead
%
\multicolumn{4}{c}
{{ \tablename\ \thetable{}: continued }} \\ 
\hline
Sub-cases & $K$ & $\tau_I$ & $\tau_D$ \\ \hline %& Stability (necessary criterion) \\ \hline
\endhead

1.1 \newline $\zeta_1>0$ $\zeta_2>0$ $\zeta_3>0$ & 

$K>\underline{K}_{0}^{nc}$ 
&
$max(0,\underline{I}_{1},\underline{I}_{1.1,1})<\tau_I<\overline{I}_{1.1,1}$ \newline
$\underline{I}_{1}=|q_2|$ \newline
$\underline{I}_{1.1,1}=\frac{|A|}{B-|C|}$ \newline
$\overline{I}_{1.1,1}=\frac{A}{B|C|+|D|}$ 
&
$max(0,\underline{D}_{1.1,1},\underline{D}_{1.1,2})<\tau_D<min(\overline{D}_{1.1,1},\overline{D}_{1.1,2})$ \newline
$\overline{D}_{1.1,1}=\frac{E}{|R|}$ \newline 
$\overline{D}_{1.1,2}=\frac{G-|R||T|}{|Y|}$; where $B>K$ \newline
$\underline{D}_{1.1,1}={|E|}$ \newline
$\underline{D}_{1.1,2}=\frac{H+F|W|}{G}$; where $G>|ZJ|$
\\  \cline{2-4}
&
\multicolumn{2}{l}{\includegraphics[trim=0 0 0 -5,width=8cm,height=5cm]{nyquistplot} }
&
\multicolumn{1}{l|}{Not stable}      \\ \hline

\endlastfoot

\end{longtable}
\end{center}

\end{document}
1
  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Alessandro Cuttin Dec 14 '16 at 11:55
2

You could use \captionof{figure} from the caption or capt-of packages which would make the caption use the figure counter but this would not necessarily produce a good result: The float would still be a table and stay in sequence with other tables, but would float past floating figures, so your final document could have Figure 2 before Figure 1.

Just use figure not table

\begin{figure}

\centering

\caption{My caption}

\label{my-label}

\begin{tabular}{|c|c|}

\hline

case 1 & \includegraphics[width=8cm,height=5cm]{case1.eps} \\ \hline

\end{tabular}

\end{figure}
2
  • I would like to add the figure caption to the case1.eps figure, but not the table environment – QiuHan Dec 14 '16 at 9:50
  • @QiuHan do you mean your real exmple has some actual text in the table and a table caption as well as a figure caption? in which case you can use \captionof, otherwise I don't understand your comment, – David Carlisle Dec 14 '16 at 9:56
0

If I understood your question right, than you looking for something like this:

enter image description here

Captions in the longtable seems to be only in the table head, so for caption of included figure you should use approach as it is used in your MWE for table captions on the next packages. For move caption on the top of cell the baseline of image had to be appropriate set. For this I use valign=t from \adjustbox package. Space around image is set by macro margin also from adjustbox. If the original images had to be trimmed, you can do this as you in your MWE.

Some off-topic comments:

  • max and min are operators, they should be used as \max and \min
  • longtable is always centered on the page, so the center environment is surplus
  • all content in your columns are horizontally centered, so the use of \multicolumn{1}{c}{...} is surplus

Complete MWE:

\documentclass[review,12pt]{elsarticle}
\usepackage{graphicx}
%\usepackage[table]{xcolor} % not used
\usepackage{longtable}
\newcolumntype{C}[1]{>{\centering\arraybackslash} p{#1}}% for shorter coding of columns type
\usepackage{caption}
\usepackage[export]{adjustbox}

\begin{document}
%\begin{center}% surplus
\begin{longtable}[ht]{|C{1.8cm}|C{3cm}|C{4cm}|C{4cm}|}%>{\raggedright\arraybackslash} p{5cm}|}
    \caption{Stability of PID controller for case 1 based on theorem 1}
\label{tab:stabilitync1}
                                                    \\
\hline
\multicolumn{4}{|c|}{case 1: $q_1<0$ and $q_2<0$}   \\ \hline
Sub-cases   & $K$   & $\tau_I$  & $\tau_D$          \\ \hline %& Stability (necessary criterion) \\ \hline
\endfirsthead
%
\hline
%\multicolumn{4}{c}{\caption{continued}}             \\ \hline
Sub-cases   & $K$   & $\tau_I$  & $\tau_D$          \\ \hline %& Stability (necessary criterion) \\
\endhead
1.1 \newline $\zeta_1>0$ $\zeta_2>0$ $\zeta_3>0$ 
    & $K>\underline{K}_{0}^{nc}$
    & $\max(0,\underline{I}_{1},\underline{I}_{1.1,1})<\tau_I<\overline{I}_{1.1,1}$ \newline
      $\underline{I}_{1}=|q_2|$ \newline
      $\underline{I}_{1.1,1}=\frac{|A|}{B-|C|}$ \newline
      $\overline{I}_{1.1,1}=\frac{A}{B|C|+|D|}$
    & $\max(0,\underline{D}_{1.1,1},
              \underline{D}_{1.1,2})<\tau_D<\min(\overline{D}_{1.1,1},
              \overline{D}_{1.1,2})$ \newline
      $\overline{D}_{1.1,1}=\frac{E}{|R|}$ \newline
      $\overline{D}_{1.1,2}=\frac{G-|R||T|}{|Y|}$; where $B>K$ \newline
      $\underline{D}_{1.1,1}={|E|}$ \newline
      $\underline{D}_{1.1,2}=\frac{H+F|W|}{G}$; where $G>|ZJ|$
                                                    \\  \cline{2-4}
    & \multicolumn{2}{c}{\includegraphics[margin=0ex 2ex, width=7cm,height=5cm,
                                          valign=t]{example-image}}%nyquistplot
    & \refstepcounter{figure}% for proper numbering and referencing of figure and
      \small
      Figure~\thefigure: Not stable                \\  \hline
\end{longtable}
%\end{center}
\end{document}

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.