def test_repr_latex(): """ Tests the _repr_latex_ method of astropy.table.Table class. Output should be a latex formatted table returned as a string. Test for PR related to issue #3972. """ a = [1, 2, 3, 5] b = np.array([4, 5, 6, 5]) c = ['hello', 'konichiwa', 'namaskar', 'guten morgen'] d = [2, 3, 5, 10] * u.m / u.s**2 t = Table([a, b, c, d], names=('val', 'val1', 'greeting', 'speed')) lTable1 = [ r'\begin{table}', r'\begin{tabular}{cccc}', r'val & val1 & greeting & speed \\', r' & & & $\mathrm{m\,s^{-2}}$ \\', r'1 & 4 & hello & 2.0 \\', r'2 & 5 & konichiwa & 3.0 \\', r'3 & 6 & namaskar & 5.0 \\', r'5 & 5 & guten morgen & 10.0 \\', r'\end{tabular}', r'\end{table}' ] assert t._repr_latex_().splitlines() == lTable1 lTable2 = [ r'\begin{table}', r'\caption{this is a table}', r'\begin{tabular}{cccc}', r'val & val1 & greeting & speed \\', r' & & & $\mathrm{m\,s^{-2}}$ \\', r'1 & 4 & hello & 2.0 \\', r'2 & 5 & konichiwa & 3.0 \\', r'3 & 6 & namaskar & 5.0 \\', r'5 & 5 & guten morgen & 10.0 \\', r'\end{tabular}', r'\end{table}' ] t.meta['latexdict'] = {'caption': 'this is a table'} assert t._repr_latex_().splitlines() == lTable2