I'm porting my original Latex file to include Lualatex code, as I'm reading an input JSON file. I'm unable to get 'resizebox' to work with luacode, without it my table shows up but I want the table aligned to textwidth like in my original tex file. Any leads pelase? JOSN:
{
"ID":"ProjectionParams",
"tableEntries":{
"PROJECTION":"UNIVERSAL TRANSVERSE MERCATOR (UTM)",
"SEMI-MAJOR":"0",
"INVERSE FLATTENING OF REFERENCE ELLIPSOID":"0",
"SCALE FACTOR ALONG THE CENTRAL MERIDIAN":"0",
"WORLD MAGNETIC MODEL":"0"
}
}
MAIN.Tex
\documentclass[12pt]{article}
\usepackage[document]{ragged2e}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[nohead,paperheight=11.0in,paperwidth=8.5in,left=0.5in,right=0.5in,top=0.5in,bottom=1.0in]{geometry}
%%%%% dynamic table package %%%%%
\usepackage{datatool}
\DTLsetseparator{,}% Set the separator between the columns.
\usepackage{longtable}
\usepackage{tabularx}
\usepackage{amsmath}
\usepackage{hhline}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{color, colortbl}
\usepackage[table]{xcolor}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{float}
\usetikzlibrary{shapes.symbols,shapes.geometric,shadows,arrows.meta}
\tikzset{>={Latex[width=1.5mm,length=2mm]}}
%conditionals package
\usepackage{xparse}
\usepackage{etoolbox}
\renewcommand{\arraystretch}{1.5} %cell height
\usepackage{luacode}
\begin{document}
\begin{FlushLeft}
ISOGONIC LINES PROGRAM
\end{FlushLeft}
\input{projection.tex}
\end{document}
projection.tex ( TEX):
\section*{PROJECTION PARAMETERS}
\begin{tikzpicture}
\begin{scope}[yscale=1,xscale=-1,xshift=-7.5in]
\draw (-0.04in,-0.22in) -- (7.54in,-0.27in);
\end{scope}
\end{tikzpicture}
%%% Tex input to table %%%
\begin{table}[H]
\resizebox{\textwidth}{!}{%
\begin{tabular}{cc}
\hline
%row no:1
\multicolumn{1}{|p{3.55in}}{\textbf{PROJECTION}}&
\multicolumn{1}{|p{3.55in}|}{\PROJECTION}\
\hhline{--}
%row no:2
\multicolumn{1}{|p{3.55in}}{\textbf{SEMI-MAJOR AXIS OF REFERENCE ELLIPSOID (METERS):}} &
\multicolumn{1}{|p{3.55in}|}{\SEMIMAJOR} \
\hhline{--}
\end{tabular}
}
\end{table}
projection.tex (Lualatex ):
\section*{PROJECTION PARAMETERS}
\begin{tikzpicture}
\begin{scope}[yscale=1,xscale=-1,xshift=-7.5in]
\draw (-0.04in,-0.22in) -- (7.54in,-0.27in);
\end{scope}
\end{tikzpicture}
\begin{luacode}
local json = require("json")
local file = io.open("data.json")
tab = json.parse(file:read("*all"))
file:close()
tex.print("\\begin{table}[H]")
tex.print("\\resizebox{\textwidth}{!}{%")
tex.print("\\begin{tabular}{|c|c|}")
tex.print("\\hline")
tex.print("{PROJECTION} &")
tex.print(tab["tableEntries"]["PROJECTION"])
tex.print("\\\\ \\hhline{--}")
tex.print("{SEMI-MAJOR AXIS OF REFERENCE ELLIPSOID (METERS)} &")
tex.print(tab["tableEntries"]["SEMI-MAJOR"])
tex.print("\\\\ \\hhline{--}")
tex.print("\\end{tabular}")
tex.print("\\}")
tex.print("\\end{table}")
\end{luacode}
End Table:


\begin{tabular}{|*{2}{p{\dimexpr 0.5\textwidth-2\tabcolsep-1.5\arrayrulewidth}|}} \hline \textbf{PROJECTION}& \PROJECTION\\ \hhline{--} \textbf{SEMI-MAJOR AXIS OF REFERENCE ELLIPSOID (METERS):} & \SEMIMAJOR \\ \hhline{--} \end{tabular}should result in a table that fits into the available space. – leandriis May 10 '21 at 20:01\resizeboxwith tables should be avoided at all costs, it is bound to produce fonts and rule widths inconsistent with the rest of the document. – David Carlisle May 10 '21 at 20:18\PROJECTIONand\SEMIMAJORdefined? Where might thejsonmodule be obtained from? – Mico May 10 '21 at 20:44ccand then every cell is usiing\multicolumnto replace that byp? If your table uses twopcolumns you know in advance how wide it is, so you can choose a width that fits so no scaling is needed. – David Carlisle May 10 '21 at 20:50data.json. I asked how to obtain thejsonmodule. – Mico May 10 '21 at 20:50\documentclassto\end{document}– David Carlisle May 10 '21 at 20:51\resizeboxandtabularetc are not handled by the lua code at all, to Lua it is just a string that is written to the tex document to be interpreted as tex. – David Carlisle May 10 '21 at 21:14tex.printthere is nothing special about tables in that step. – David Carlisle May 11 '21 at 07:38\PROJECTIONand\SEMIMAJORare defined. (Aside: What's with the ALL-UPPERCASE stuff?) And your posting continues to provide no reason for why one might want to employ aluacodeenvironment. Sadly, my mind-reading skills are simply worthless. Unless you start providing actionable information, the odds that someone will manage to figure what you're trying to achieve are bleak. – Mico May 11 '21 at 08:59\newcommand{\PROJECTION}{UNIVERSAL TRANSVERSE MERCATOR (UTM)} \newcommand{\SEMIMAJOR}{6378137.000} --- 2. and the uppercase is how the mocked up WORD report that itry to rewrite in Latex 3. the reason for the luacode is read json file entries( cudnt do with plain tex) and loop through the objects to create a table with the json entries
– 24suns May 11 '21 at 10:23