r"""
    Args:
        fpath_list (list):
        dpath (str): directory relative to main tex file

    Returns:
        str: figure_str

    CommandLine:
        python -m utool.util_latex --test-get_latex_figure_str

    Example:
        >>> # DISABLE_DOCTEST
        >>> from utool.util_latex import *  # NOQA
        >>> fpath_list = ['figures/foo.png']
        >>> figure_str = get_latex_figure_str(fpath_list)
        >>> result = str(figure_str)
        >>> print(result)

def get_latex_figure_str(fpath_list, caption_str=None, label_str=None,
                         width_str=r'\textwidth', height_str=None, nCols=None,
                         dpath=None, colpos_sep=' ', nlsep='',
                         use_sublbls=None, use_frame=False):
    r"""
    Args:
        fpath_list (list):
        dpath (str): directory relative to main tex file

    Returns:
        str: figure_str

    CommandLine:
        python -m utool.util_latex --test-get_latex_figure_str

    Example:
        >>> # DISABLE_DOCTEST
        >>> from utool.util_latex import *  # NOQA
        >>> fpath_list = ['figures/foo.png']
        >>> figure_str = get_latex_figure_str(fpath_list)
        >>> result = str(figure_str)
        >>> print(result)
    """
    import utool as ut

    if nCols is None:
        nCols = len(fpath_list)

    USE_SUBFIGURE = True

    if width_str is not None:
        colwidth = (1.0 / nCols)
        if USE_SUBFIGURE:
            colwidth *= .95
            graphics_sizestr = ('%.2f' % (colwidth,)) + width_str
        else:
            graphics_sizestr = '[width=%.1f%s]' % (colwidth, width_str)
    elif height_str is not None:
        graphics_sizestr = '[height=%s]' % (height_str)
    else:
        graphics_sizestr =  ''

    if dpath is not None:
        fpath_list = [ut.relpath_unix(fpath_, dpath) for fpath_ in fpath_list]

    if USE_SUBFIGURE:
        # References: https://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions#Subfloats
        # TODO ? http://tex.stackexchange.com/questions/159290/how-can-i-place-a-vertical-rule-between-subfigures
        # Use subfigures
        graphics_list = []
        sublbl_prefix = label_str if label_str is not None else ''
        for count, fpath in enumerate(fpath_list):
            """
            print(', '.join([str(x) + ':' + chr(x) for x in range(65, 123)]))
            print(', '.join([str(x) + ':' + chr(x) for x in range(97, 123)]))
            """
            CHRLBLS = True
            if CHRLBLS:
                #subchar = chr(97 + count)
                subchar = chr(65 + count)
            else:
                subchar = str(count)
            parts = []
            subfigure_str = ''
            if len(fpath_list) > 1:
                parts.append('\\begin{subfigure}[h]{' + graphics_sizestr + '}')
                parts.append('\\centering')
            graphics_part = '\\includegraphics[width=%s]{%s}' % (width_str, fpath,)
            if use_frame:
                parts.append('\\fbox{%s}' % (graphics_part,))
            else:
                parts.append(graphics_part)
            if use_sublbls is True or use_sublbls is None and len(fpath_list) > 1:
                parts.append('\\caption{}\\label{sub:' + sublbl_prefix + subchar + '}')
            if len(fpath_list) > 1:
                parts.append('\\end{subfigure}')
            subfigure_str = ''.join(parts)
            graphics_list.append(subfigure_str)
    else:
        if True:
            graphics_list = [
                r'\includegraphics%s{%s}\captionof{figure}{%s}' % (
                    graphics_sizestr, fpath, 'fd',
                    #'(' + str(count) + ')'
                    #'(' + chr(97 + count) + ')'
                )
                for count, fpath in enumerate(fpath_list)]
        else:
            graphics_list = [r'\includegraphics%s{%s}' % (graphics_sizestr, fpath,) for fpath in fpath_list]
        #graphics_list = [r'\includegraphics%s{%s}' % (graphics_sizestr, fpath,) ]
    #nRows = len(graphics_list) // nCols

    # Add separators
    NL = '\n'
    if USE_SUBFIGURE:
        col_spacer_mid = NL + '~~' + '% --' + NL
        col_spacer_end = NL + r'\\' + '% --' + NL
    else:
        col_spacer_mid = NL + '&' + NL
        col_spacer_end = NL + r'\\' + nlsep + NL
    sep_list = [
        col_spacer_mid  if count % nCols > 0 else col_spacer_end
        for count in range(1, len(graphics_list) + 1)
    ]
    if len(sep_list) > 0:
        sep_list[-1] = ''
    graphics_list_ = [graphstr + sep for graphstr, sep in zip(graphics_list, sep_list)]

    #graphics_body = '\n&\n'.join(graphics_list)
    graphics_body = ''.join(graphics_list_)
    header_str = colpos_sep.join(['c'] * nCols)

    if USE_SUBFIGURE:
        figure_body = graphics_body
    else:
        figure_body =  ut.codeblock(
            r'''
            \begin{tabular}{%s}
            %s
            \end{tabular}
            '''
        ) % (header_str, graphics_body)
    if caption_str is not None:
        #tabular_body += '\n\caption{\\footnotesize{%s}}' % (caption_str,)
        if label_str is not None:
            figure_body += '\n\caption[%s]{%s}' % (label_str, caption_str,)
        else:
            figure_body += '\n\caption{%s}' % (caption_str,)
    if label_str is not None:
        figure_body += '\n\label{fig:%s}' % (label_str,)
    #figure_fmtstr = ut.codeblock(
    #    r'''
    #    \begin{figure*}
    #    \begin{center}
    #    %s
    #    \end{center}
    #    \end{figure*}
    #    '''
    #)
    figure_fmtstr = ut.codeblock(
        r'''
        \begin{figure}[ht!]
        \centering
        %s
        \end{figure}
        '''
    )
    figure_str = figure_fmtstr % (figure_body)
    return figure_str