From c5ba3b8ee32704f1fdf241480ba64950f8ceedd8 Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Wed, 10 Jan 2018 12:28:42 -0800
Subject: [PATCH] LaTeX reader: fix inconsistent column widths.

This fixes a bug whereby column widths for the body were
different from widths for the header in some tables.

Closes #4238.
---
 src/Text/Pandoc/Writers/LaTeX.hs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index 296b30ee1..49b39f014 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -749,9 +749,9 @@ tableRowToLaTeX header aligns widths cols = do
       isSimple []        = True
       isSimple _         = False
   -- simple tables have to have simple cells:
-  let widths' = if not (all isSimple cols)
+  let widths' = if all (== 0) widths && not (all isSimple cols)
                    then replicate (length aligns)
-                          (0.97 / fromIntegral (length aligns))
+                          (scaleFactor / fromIntegral (length aligns))
                    else map (scaleFactor *) widths
   cells <- mapM (tableCellToLaTeX header) $ zip3 widths' aligns cols
   return $ hsep (intersperse "&" cells) <> "\\tabularnewline"