1

the latex source is as follows:

  \begin{figure}[h]
    \begin{centering}
    \protect\caption{Accuracies comparision of different methods \label{fig:comparision}}

    \par\end{centering}

    \begin{minipage}[t]{0.96\columnwidth}%
    \noindent \begin{center}
    \begin{minipage}[t]{0.45\columnwidth}%
    \subfloat[\label{fig:comparison1}comparison1]{

    \protect\centering{}\protect\includegraphics[scale=0.25]{Comparision_0}\protect}%
    \end{minipage}\quad{}%
    \begin{minipage}[t]{0.45\columnwidth}%
    \subfloat[\label{fig:comparison2}comparison2]{

    \protect\centering{}\protect\includegraphics[scale=0.25]{Comparision_1}\protect}%
    \end{minipage}
    \par\end{center}%
    \end{minipage}
    \end{figure}

And, when I reference Fig. \ref{fig:comparison}, it shows Fig. 7, which is right. But, when I reference Fig. \ref{fig:comparison1} and Fig. \ref{fig:comparison2}, it shows Fig. 8(a) and Fig. 8(b) which I expect Fig. 7(a) and Fig. 7(b).

Could you help give some advice, please? Thanks!

UPDATED:

The source of lyx file is as follows:

    #LyX 2.1 created this file. For more info see http://www.lyx.org/
    \lyxformat 474
    \begin_document
    \begin_header
    \textclass IEEEtran
    \begin_preamble
    % for subfigures/subtables
    \usepackage[caption=false,font=footnotesize]{subfig}

    \usepackage{algorithm,algpseudocode}

    \usepackage{hyperref}
    \hypersetup{backref,colorlinks,linktocpage=true}

    \usepackage{array}
    \usepackage{booktabs}

    \def\hlinew#1{%
      \noalign{\ifnum0=`}\fi\hrule \@height #1 \futurelet
       \reserved@a\@xhline}

    %\usepackage{subfig}
    %\captionsetup[subfloat]{position=top,farskip=10pt,topadjust=0pt,captionskip=10pt,nearskip=10pt,margin=10pt}
    \end_preamble
    \options journal
    \use_default_options false
    \maintain_unincluded_children false
    \language english
    \language_package default
    \inputencoding default
    \fontencoding global
    \font_roman default
    \font_sans default
    \font_typewriter default
    \font_math auto
    \font_default_family default
    \use_non_tex_fonts false
    \font_sc false
    \font_osf false
    \font_sf_scale 100
    \font_tt_scale 100
    \graphics default
    \default_output_format default
    \output_sync 0
    \bibtex_command bibtex
    \index_command default
    \float_placement tbh
    \paperfontsize default
    \spacing single
    \use_hyperref true
    \pdf_title "Your Title"
    \pdf_author "Your Name"
    \pdf_bookmarks true
    \pdf_bookmarksnumbered true
    \pdf_bookmarksopen true
    \pdf_bookmarksopenlevel 1
    \pdf_breaklinks false
    \pdf_pdfborder true
    \pdf_colorlinks false
    \pdf_backref false
    \pdf_pdfusetitle false
    \pdf_quoted_options "pdfpagelayout=OneColumn, pdfnewwindow=true, pdfstartview=XYZ, plainpages=false"
    \papersize default
    \use_geometry false
    \use_package amsmath 1
    \use_package amssymb 1
    \use_package cancel 0
    \use_package esint 0
    \use_package mathdots 1
    \use_package mathtools 0
    \use_package mhchem 1
    \use_package stackrel 0
    \use_package stmaryrd 0
    \use_package undertilde 0
    \cite_engine basic
    \cite_engine_type default
    \biblio_style IEEEtran
    \use_bibtopic false
    \use_indices false
    \paperorientation portrait
    \suppress_date false
    \justification true
    \use_refstyle 0
    \index Index
    \shortcut idx
    \color #008000
    \end_index
    \secnumdepth 3
    \tocdepth 3
    \paragraph_separation indent
    \paragraph_indentation default
    \quotes_language english
    \papercolumns 2
    \papersides 1
    \paperpagestyle default
    \tracking_changes false
    \output_changes false
    \html_math_output 0
    \html_css_as_file 0
    \html_be_strict false
    \end_header

    \begin_body

    \begin_layout Standard
    Fig.

    \begin_inset CommandInset ref
    LatexCommand ref
    reference "fig:comparision"

    \end_inset

    .
     As shown in Fig.

    \begin_inset CommandInset ref
    LatexCommand ref
    reference "fig:comparision1"

    \end_inset

    , From the Fig.

    \begin_inset CommandInset ref
    LatexCommand ref
    reference "fig:comparision2"

    \end_inset

    , 
    \end_layout

    \begin_layout Standard
    \begin_inset Float figure
    placement h
    wide false
    sideways false
    status open

    \begin_layout Plain Layout
    \align center
    \begin_inset Caption Standard

    \begin_layout Plain Layout
    Classification accuracies comparision of different methods.

    \begin_inset CommandInset label
    LatexCommand label
    name "fig:comparision"

    \end_inset


    \end_layout

    \end_inset


    \end_layout

    \begin_layout Plain Layout
    \begin_inset Box Frameless
    position "t"
    hor_pos "c"
    has_inner_box 1
    inner_pos "t"
    use_parbox 0
    use_makebox 0
    width "96col%"
    special "none"
    height "1in"
    height_special "totalheight"
    status open

    \begin_layout Plain Layout
    \noindent
    \align center
    \begin_inset Box Frameless
    position "t"
    hor_pos "c"
    has_inner_box 1
    inner_pos "t"
    use_parbox 0
    use_makebox 0
    width "45col%"
    special "none"
    height "1in"
    height_special "totalheight"
    status open

    \begin_layout Plain Layout
    \begin_inset Float figure
    wide false
    sideways false
    status open

    \begin_layout Plain Layout
    \begin_inset Caption Standard

    \begin_layout Plain Layout
    \begin_inset CommandInset label
    LatexCommand label
    name "fig:comparision1"

    \end_inset

    comparison1
    \end_layout

    \end_inset


    \end_layout

    \begin_layout Plain Layout
    \align center
    \begin_inset Graphics
        filename /home/ubuntu/Desktop/img1.eps
        lyxscale 50
        scale 50

    \end_inset


    \end_layout

    \end_inset


    \end_layout

    \end_inset


    \begin_inset space \quad{}
    \end_inset


    \begin_inset Box Frameless
    position "t"
    hor_pos "c"
    has_inner_box 1
    inner_pos "t"
    use_parbox 0
    use_makebox 0
    width "45col%"
    special "none"
    height "1in"
    height_special "totalheight"
    status open

    \begin_layout Plain Layout
    \begin_inset Float figure
    wide false
    sideways false
    status open

    \begin_layout Plain Layout
    \begin_inset Caption Standard

    \begin_layout Plain Layout
    \begin_inset CommandInset label
    LatexCommand label
    name "fig:comparision2"

    \end_inset

    comparison2
    \end_layout

    \end_inset


    \end_layout

    \begin_layout Plain Layout
    \align center
    \begin_inset Graphics
        filename /home/ubuntu/Desktop/img2.eps
        lyxscale 20
        scale 10

    \end_inset


    \end_layout

    \end_inset


    \end_layout

    \end_inset


    \end_layout

    \end_inset


    \end_layout

    \end_inset


    \end_layout

    \end_body
    \end_document

And the visualization in lyx editor is as follows:

enter image description here

And the generated pdf is as follows:

enter image description here

And I export the lyx into the plain Latex as follows:

    %% LyX 2.1.3 created this file.  For more info, see http://www.lyx.org/.
    %% Do not edit unless you really know what you are doing.
    \documentclass[twocolumn,english,journal]{IEEEtran}
    \usepackage[T1]{fontenc}
    \usepackage{babel}
    \usepackage{graphicx}
    \usepackage[unicode=true,
     bookmarks=true,bookmarksnumbered=true,bookmarksopen=true,bookmarksopenlevel=1,
     breaklinks=false,pdfborder={0 0 0},backref=false,colorlinks=false]
     {hyperref}
    \hypersetup{pdftitle={Your Title},
     pdfauthor={Your Name},
     pdfpagelayout=OneColumn, pdfnewwindow=true, pdfstartview=XYZ, plainpages=false}
    \usepackage{breakurl}

    \makeatletter
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
    % for subfigures/subtables
    \usepackage[caption=false,font=footnotesize]{subfig}

    \usepackage{algorithm,algpseudocode}

    \usepackage{hyperref}
    \hypersetup{backref,colorlinks,linktocpage=true}

    \usepackage{array}
    \usepackage{booktabs}

    \def\hlinew#1{%
      \noalign{\ifnum0=`}\fi\hrule \@height #1 \futurelet
       \reserved@a\@xhline}

    %\usepackage{subfig}
    %\captionsetup[subfloat]{position=top,farskip=10pt,topadjust=0pt,captionskip=10pt,nearskip=10pt,margin=10pt}

    \@ifundefined{showcaptionsetup}{}{%
     \PassOptionsToPackage{caption=false}{subfig}}
    \usepackage{subfig}
    \makeatother

    \begin{document}
    Fig. \ref{fig:comparision}. As shown in Fig. \ref{fig:comparision1},
    From the Fig. \ref{fig:comparision2}, 

    \begin{figure}[h]
    \begin{centering}
    \protect\caption{Classification accuracies comparision of different methods. \label{fig:comparision}}

    \par\end{centering}

    \begin{minipage}[t]{0.96\columnwidth}%
    \noindent \begin{center}
    \begin{minipage}[t]{0.45\columnwidth}%
    \subfloat[\label{fig:comparision1}comparison1]{

    \protect\centering{}\protect\includegraphics[scale=0.5]{/home/ubuntu/Desktop/img1}\protect}%
    \end{minipage}\quad{}%
    \begin{minipage}[t]{0.45\columnwidth}%
    \subfloat[\label{fig:comparision2}comparison2]{

    \protect\centering{}\protect\includegraphics[scale=0.1]{/home/ubuntu/Desktop/img2}\protect}%
    \end{minipage}
    \par\end{center}%
    \end{minipage}
    \end{figure}

    \end{document}
  • please always post full small documents not just fragments, so people can test, but just looking at it \begin{centering} should be \centering , \protect\caption should be \caption, \noindent \begin{center} should be \centering, \protect\centering{} should be \centering, no \protect in front of \includegraphics and never \protect in front of } – David Carlisle Mar 27 '15 at 1:12
  • Hi, @DavidCarlisle, thank you for replying! I use the Lyx 2.1 editor to edit the lyx document. Thus, I couldn't modify manually these commands as you suggested. – mining Mar 27 '15 at 1:17
  • @DavidCarlisle, those \protects and \pars are automatically generated by the Lyx editor, thus I couldn't delete them manually. – mining Mar 27 '15 at 1:20
  • @mining please post a complete .tex file and a complete .lyx file (.lyx files are just text files). – scottkosty Mar 27 '15 at 2:36
  • Hi, @DavidCarlisle, I've update the post with the complete source of the lyx file. If convenient, please help check it. Thanks! – mining Mar 27 '15 at 2:55
2

Don't say caption=false if you want to use captions....

numbered subfigures

\documentclass[twocolumn,journal]{IEEEtran}
\usepackage[demo]{graphicx}
\usepackage[font=footnotesize]{subfig}

\begin{document}
  Fig. \ref{fig:comparision}. As shown in Fig. \ref{fig:comparision1},
  From the Fig. \ref{fig:comparision2},

  \begin{figure}[h]
    \centering
     \caption{Classification accuracies comparision of different methods. \label{fig:comparision}}
     \subfloat[\label{fig:comparision1}comparison1]{%
        \includegraphics[scale=0.5]{/home/ubuntu/Desktop/img1}}\thinspace
        \subfloat[\label{fig:comparision2}comparison2]{%
        \includegraphics[scale=0.1]{/home/ubuntu/Desktop/img2}}
  \end{figure}

\end{document}

Note that my code produces an overfull hbox. Presumably this is because I'm using demo mode as I don't have the images. Hence, I've not bothered to try to eliminate the issue as it is not germane to the current question.

| improve this answer | |
  • Hi, @cfr, thank you very for replying! In fact, I use LyX for writing the paper. But the final plain Latex version of the paper should be submitted. However, as an editor, I think LyX is suitable for the work. However, I think the limit that it cannot edit directly the Latex source code should be improved. – mining Mar 27 '15 at 3:54
  • And I delete the caption=false in the preamble, but the issue still occurs. – mining Mar 27 '15 at 3:55
  • @mining Note that the code you posted loads the package with caption=false at least once, but possibly twice. Did you remove both? Or ensure that the second conditional is not activated? – cfr Mar 27 '15 at 4:19
  • the second caption=false is generated by the LyX itself, thus I couldn't delete it manually. – mining Mar 27 '15 at 4:35
  • @mining Then you have to make sure the antecedent of the conditional is true so that that option is not passed to subfig, I suppose. Unless there is some other way of making LyX behave nicely. It is hard to believe that that option is forced on you. – cfr Mar 27 '15 at 16:42
0

If you put the "Figure 1" caption below the subfigures, everything works fine for me!

| improve this answer | |

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.