def latexToArrayRowNames(text):
    """Converts the inside of the LaTeX tabular environment into a 2D array represented as nested lists.
    The first column is treated as row names, and a list of them is returned."""
    rows = []
    names = []
    for line in text.strip().split("\n"):
        cols = [c.strip() for c in line.split("&")]
        if cols[-1].endswith(r"\\"):
            cols[-1] = cols[-1][:-2]
        elif cols[-1].endswith(r"\\\hline"):
            cols[-1] = cols[-1][:-8]
        names.append(cols[0])
        rows.append(cols[1:])
    return rows, names