MCPcopy Index your code
hub / github.com/SLiCAP/SLiCAP_python / _TEXcreateCSVtable

Function _TEXcreateCSVtable

SLiCAP/SLiCAPlatex.py:894–961  ·  view source on GitHub ↗

Creates and returns a LaTeX table snippet that can be included in a LaTeX document. A label can be given as reference and a caption can be added. :param headerList: List with column headers. :type headerList: list with strings :param linesList: List with lists of table data f

(headerList, linesList, alignstring, unitpos=None, caption='', label='', color="myyellow")

Source from the content-addressed store, hash-verified

892# Non-public functions for creating table snippets
893
894def _TEXcreateCSVtable(headerList, linesList, alignstring, unitpos=None, caption='', label='', color="myyellow"):
895 """
896 Creates and returns a LaTeX table snippet that can be included in a LaTeX document.
897
898 A label can be given as reference and a caption can be added.
899
900 :param headerList: List with column headers.
901 :type headerList: list with strings
902
903 :param linesList: List with lists of table data for each table row
904 :type linesList: list
905
906 :param alignstring: LaTeX table align string
907 :type alignstring: str
908
909 :param unitpos: Position of column with units (will be typesetted with mathrm)
910 :type unitpos: int, str
911
912 :param caption: Table caption, defauls to ''
913 :type caption: str
914
915 :param label: Table reference label
916 :type label: str
917
918 :param color: Alternate row color name, should be defined in
919 'preambuleSLiCAP.tex' defaults to 'myyellow'. Use None for
920 no background color.
921 :type color: str
922
923 :return: LaTeX snippet to be included in a LaTeX document
924 :rtype: str
925 """
926 if caption != '' or label != '':
927 TEX = '\\begin{table}[h]\n\\centering\n'
928 else:
929 TEX = ''
930 TEX += '\\begin{tabular}' + alignstring + '\n'
931 for field in headerList:
932 if type(field) == str:
933 TEX += '\\textbf{' + field + '} & '
934 else:
935 TEX += '$\\mathbf{' + sp.latex(roundN(field)) + '}$ & '
936 TEX = TEX[:-2] + '\\\\ \n'
937 j = 0
938 for line in linesList:
939 i = 0
940 if not j%2 and color != None:
941 TEX += '\\rowcolor{%s}\n'%(color)
942 for field in line:
943 if unitpos != None and i == int(unitpos):
944 TEX += '$\\mathrm{' + units2TeX(field) + '}$ &'
945 elif type(field) == str:
946 if field != '':
947 TEX += '\\small{' + field.replace('_', '\\_') + '} &'
948 else:
949 TEX += ' &'
950 else:
951 TEX += '$' + sp.latex(roundN(sp.N(field))) + '$ &'

Callers 11

elementDataMethod · 0.85
parDefsMethod · 0.85
dictTableMethod · 0.85
paramsMethod · 0.85
pzMethod · 0.85
noiseContribsMethod · 0.85
dcvarContribsMethod · 0.85
specsMethod · 0.85
stepArrayMethod · 0.85
coeffsTransferMethod · 0.85
nestedListsMethod · 0.85

Calls 2

roundNFunction · 0.90
units2TeXFunction · 0.90

Tested by

no test coverage detected