diff --git a/CHANGES.rst b/CHANGES.rst
index 347644a..92f43a7 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -7,6 +7,11 @@ Change History
 Production
 **********
 
+:2020.0.1: expected *2019.08* - bug fix
+
+    * `#31 <https://github.com/prjemian/pyRestTable/issues/31>`_
+      fix bug in column width detection
+
 :2020.0.0: 2019.07.09 - packaging and code review
 
     * `#28 <https://github.com/prjemian/pyRestTable/issues/28>`_
diff --git a/src/pyRestTable/rest_table.py b/src/pyRestTable/rest_table.py
index 7c2055d..316996d 100644
--- a/src/pyRestTable/rest_table.py
+++ b/src/pyRestTable/rest_table.py
@@ -372,15 +372,24 @@ class Table(object):
         measure the maximum width of each column, 
         considering possible line breaks in each cell
         """
+        
+        def col_widths(columns):
+            result = []
+            for s in columns:
+                # if multi-line, get width of biggest line
+                widths = [len(p) for p in str(s).split("\n")]
+                result.append(max(widths))
+            return result
+        
         width = []
         if len(self.labels) > 0:
-            width = [max(map(len, str(_).split("\n"))) for _ in self.labels]
+            width = col_widths(self.labels)
         for row in self.rows:
             
-            row_width = [max(map(len, str(_ or '').split("\n"))) for _ in row]
+            row_width = col_widths(row)
             
             if len(width) == 0:
                 width = row_width
-            width = list(map( max, zip(width, row_width) ))
+            width = list(map(max, zip(width, row_width) ))
         return width
 

incorrect column widths
```
import pyRestTable
table = pyRestTable.Table()
table.labels = ['h', 'k', 'l', 'mu', 'omega', 'chi', 'phi', 'gamma', 'delta']
table.addRow([0, 1, 1, 0.0, 3.4824458166048444, 22.712897698011936, 0.0, 0.0, 13.799774663132288])
table.addRow([0.0, 8.0, 0.0, 0.0, 22.31594087562736, 89.13769999977886, 0.0, 0.0, 45.158571742842376])
table.addRow([0.0, 12.0, 1.0, 0.0, 34.963469180020944, 78.33265876350477, 0.0, 0.0, 71.80070421791422])
print(table)
```

This is the output:
```
= ==== === == ================== ================== === ===== ==================
h k    l   mu omega              chi                phi gamma delta             
= ==== === == ================== ================== === ===== ==================
0 1    1   0.0 3.4824458166048444 22.712897698011936 0.0 0.0   13.799774663132288
0.0 8.0  0.0 0.0 22.31594087562736  89.13769999977886  0.0 0.0   45.158571742842376
0.0 12.0 1.0 0.0 34.963469180020944 78.33265876350477  0.0 0.0   71.80070421791422 
= ==== === == ================== ================== === ===== ==================
```

Columns `h` and `mu` should be wider.
diff --git a/tests/test_results.py b/tests/test_results.py
index 8927bb8..06257ee 100644
--- a/tests/test_results.py
+++ b/tests/test_results.py
@@ -219,9 +219,6 @@ EXAMPLE_COMPLICATED_RESULT = '''
 
 class Test_pyRestTable(unittest.TestCase):
     
-    def setUp(self):
-        pass
-    
     def apply_test(self, table, reference_text, style='simple'):
         text = table.reST(fmt=style)
         self.assertTrue(text.strip() == reference_text.strip())
@@ -371,10 +368,53 @@ class Test_pyRestTable(unittest.TestCase):
         self.assertEqual(s, MINIMAL_SIMPLE_RESULT, 'string representation')
 
 
+class Test_column_widths(unittest.TestCase):
+
+    def test_issue_31(self):
+        table = pyRestTable.Table()
+        table.labels = ['h', 'k', 'l', 'mu', 'omega', 'chi', 'phi', 'gamma', 'delta']
+        table.addRow([0, 1, 1, 0.0, 3.4824458166048444, 22.712897698011936, 0.0, 0.0, 13.799774663132288])
+        table.addRow([0.0, 8.0, 0.0, 0.0, 22.31594087562736, 89.13769999977886, 0.0, 0.0, 45.158571742842376])
+        table.addRow([0.0, 12.0, 1.0, 0.0, 34.963469180020944, 78.33265876350477, 0.0, 0.0, 71.80070421791422])
+
+        result = str(table).splitlines()
+
+        self.assertEqual(len(result), 7)
+        columns = result[0].split()
+        self.assertEqual(len(columns), 9)
+        
+        # this was the first problem in issue #31
+        self.assertEqual(columns[0], "===", "width of h column should be three")
+
+        expected = [
+            "=== ==== === === ================== ================== === ===== ==================",
+            "h   k    l   mu  omega              chi                phi gamma delta             ",
+            "=== ==== === === ================== ================== === ===== ==================",
+            "0   1    1   0.0 3.4824458166048444 22.712897698011936 0.0 0.0   13.799774663132288",
+            "0.0 8.0  0.0 0.0 22.31594087562736  89.13769999977886  0.0 0.0   45.158571742842376",
+            "0.0 12.0 1.0 0.0 34.963469180020944 78.33265876350477  0.0 0.0   71.80070421791422 ",
+            "=== ==== === === ================== ================== === ===== =================="
+            ]
+
+        # check the column labels are identical
+        for s, e in zip(result[1].split(), expected[1].split()):
+            self.assertEqual(s, e)
+
+        # floating point numbers might be truncated but otherwise OK
+        # check that values match to roundoff precision
+        digits = 9
+        for row in (3, 4, 5):
+            for s, e in zip(result[row].split(), expected[row].split()):
+                self.assertEqual(
+                    round(float(s), digits), 
+                    round(float(e), digits))
+
+
 def suite(*args, **kw):
     test_suite = unittest.TestSuite()
     test_list = [
         Test_pyRestTable,
+        Test_column_widths,
         ]
     for test_case in test_list:
         test_suite.addTest(unittest.makeSuite(test_case))

pip install -e .
parse_log_pytest
requirements.txt
coverage coveralls pytest
apt-get update apt-get install -y gcc
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
certifi==2025.1.31
charset-normalizer==3.4.1
coverage==7.8.0
coveralls==4.0.1
docopt==0.6.2
exceptiongroup==1.2.2
idna==3.10
iniconfig==2.1.0
lxml==5.3.1
packaging==24.2
pluggy==1.5.0
-e git+https://github.com/prjemian/pyRestTable.git@f933a4af2a453d0a2ecb9d6dcdac6a02ab3f5361#egg=pyRestTable
pytest==8.3.5
requests==2.32.3
tomli==2.2.1
urllib3==2.3.0

name: pyRestTable
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - certifi==2025.1.31
      - charset-normalizer==3.4.1
      - coverage==7.8.0
      - coveralls==4.0.1
      - docopt==0.6.2
      - exceptiongroup==1.2.2
      - idna==3.10
      - iniconfig==2.1.0
      - lxml==5.3.1
      - packaging==24.2
      - pluggy==1.5.0
      - pytest==8.3.5
      - requests==2.32.3
      - tomli==2.2.1
      - urllib3==2.3.0
prefix: /opt/conda/envs/pyRestTable

tests/test_results.py::Test_column_widths::test_issue_31
tests/test_results.py::Test_pyRestTable::test_cansas tests/test_results.py::Test_pyRestTable::test_default_str tests/test_results.py::Test_pyRestTable::test_example_basic tests/test_results.py::Test_pyRestTable::test_example_complicated tests/test_results.py::Test_pyRestTable::test_example_minimal tests/test_results.py::Test_pyRestTable::test_grid tests/test_results.py::Test_pyRestTable::test_markdown_grid tests/test_results.py::Test_pyRestTable::test_minimal_complex tests/test_results.py::Test_pyRestTable::test_minimal_grid tests/test_results.py::Test_pyRestTable::test_minimal_htmltable tests/test_results.py::Test_pyRestTable::test_minimal_listtable tests/test_results.py::Test_pyRestTable::test_minimal_simple tests/test_results.py::Test_pyRestTable::test_num_col_labels_different_from_col_width_specifiers tests/test_results.py::Test_pyRestTable::test_plain tests/test_results.py::Test_pyRestTable::test_simple tests/test_results.py::Test_pyRestTable::test_zero_columns tests/test_results.py::Test_pyRestTable::test_zero_width_column
src/pyRestTable/rest_table.py CHANGES.rst
src/pyRestTable/rest_table.py CHANGES.rst