def table(custom_headings, col_headings_formatted, rows, spec):
    """
    Create a LaTeX table

    Parameters
    ----------
    custom_headings : None, dict
        optional dictionary of custom table headings

    col_headings_formatted : list
        formatted column headings

    rows : list of lists of cell-strings
        Data in the table, pre-formatted

    spec : dict
        options for the formatter

    Returns
    -------
    dict : contains key 'latex', which corresponds to a latex string representing the table
    """
    longtables = spec['longtables']
    table = "longtable" if longtables else "tabular"
    if custom_headings is not None \
            and "latex" in custom_headings:
        latex = custom_headings['latex']
    else:
        latex = "\\begin{%s}[l]{%s}\n\hline\n" % \
            (table, "|c" * len(col_headings_formatted) + "|")
        latex += ("%s \\\\ \hline\n"
                  % (" & ".join(col_headings_formatted)))

    for formatted_rowData in rows:

        if len(formatted_rowData) > 0:
            formatted_rowData_latex = [
                (formatted_cell['latex'] if isinstance(formatted_cell, dict)
                 else formatted_cell) for formatted_cell in formatted_rowData]
            latex += " & ".join(formatted_rowData_latex)

            #MULTI-ROW support for *data* (non-col-header) rows of table.  Currently
            # unused (unneeded) - see multirow formatter that is commented out in formatters.py
            #multirows = [ ("multirow" in el) for el in formatted_rowData_latex ]
            #if any(multirows):
            #    latex += " \\\\ "
            #    last = True; lineStart = None; col = 1
            #    for multi,data in zip(multirows,formatted_rowData_latex):
            #        if last == True and multi == False:
            #            lineStart = col #line start
            #        elif last == False and multi == True:
            #            latex += "\cline{%d-%d} " % (lineStart,col) #line end
            #        last=multi
            #        res = _re.search("multicolumn{([0-9])}",data)
            #        if res: col += int(res.group(1))
            #        else:   col += 1
            #    if last == False: #need to end last line
            #        latex += "\cline{%d-%d} "%(lineStart,col-1)
            #    latex += "\n"
            #else:
            latex += " \\\\ \hline\n"

    latex += "\end{%s}\n" % table
    return {'latex': latex}