LaTeX: improve formatting
This commit is contained in:
parent
339240a8ec
commit
39ba6ec368
60
init.lua
60
init.lua
@ -312,17 +312,13 @@ end
|
||||
|
||||
advtrains_doc_integration = {}
|
||||
|
||||
local function addhline(lst)
|
||||
table.insert(lst, [[\hline]])
|
||||
end
|
||||
|
||||
function advtrains_doc_integration.write_wagon_info_as_latex(itemname)
|
||||
local filename = string.format("%satdoc_wagon_%s.tex", worldpath, itemname:gsub(":", "_"))
|
||||
local prototype = adjust_wagon_prototype(advtrains.wagon_prototypes[itemname])
|
||||
local st = {string.format([[
|
||||
\documentclass{article}
|
||||
\usepackage[a4paper,margin=1in,bottom=1.5in]{geometry}
|
||||
\usepackage{multirow,tabularx}
|
||||
\usepackage{booktabs,multirow,tabularx}
|
||||
\renewcommand{\arraystretch}{1.5}
|
||||
\title{Wagon Datasheet}
|
||||
\author{%s}
|
||||
@ -334,8 +330,7 @@ function advtrains_doc_integration.write_wagon_info_as_latex(itemname)
|
||||
if prototype.longdesc then
|
||||
table.insert(st, SL(prototype.longdesc) .. "\n")
|
||||
end
|
||||
table.insert(st, [[\begin{tabularx}{\textwidth}{|l|X|}]])
|
||||
addhline(st)
|
||||
table.insert(st, [[\begin{tabularx}{\textwidth}{l X}]])
|
||||
table.insert(st, string.format([[Itemstring & \texttt{%s}\\]], SL(itemname)))
|
||||
if prototype.drives_on then
|
||||
local i0 = #st+1
|
||||
@ -346,26 +341,20 @@ function advtrains_doc_integration.write_wagon_info_as_latex(itemname)
|
||||
end
|
||||
if count > 0 then
|
||||
st[i0] = string.format([[Drives on %s]], st[i0])
|
||||
table.insert(st, i0, [[\hline]])
|
||||
end
|
||||
end
|
||||
if prototype.wagon_span then
|
||||
addhline(st)
|
||||
table.insert(st, string.format([[Wagon span & %d mm\\]], prototype.wagon_span*2000))
|
||||
end
|
||||
if prototype.max_speed then
|
||||
addhline(st)
|
||||
table.insert(st, string.format([[Maximum speed & %d m/s\\]], prototype.max_speed))
|
||||
end
|
||||
addhline(st)
|
||||
table.insert(st, string.format([[Motive power & %s\\]], prototype.is_locomotive and "Present" or "Absent"))
|
||||
addhline(st)
|
||||
if prototype.horn_sound then
|
||||
table.insert(st, string.format([[Horn sound & \texttt{%s}\\]], SL(prototype.horn_sound.name)))
|
||||
else
|
||||
table.insert(st, [[Horn sound & Undefined\\]])
|
||||
end
|
||||
addhline(st)
|
||||
table.insert(st, [[\end{tabularx}]])
|
||||
|
||||
table.insert(st, [[\section{Coupler Compatibility}]])
|
||||
@ -391,33 +380,34 @@ function advtrains_doc_integration.write_wagon_info_as_latex(itemname)
|
||||
end
|
||||
table.sort(lcouplers)
|
||||
table.insert(st, [[
|
||||
\begin{tabularx}{\textwidth}{|X|c|c|}
|
||||
\hline
|
||||
\multirow{2}{*}{Coupler Type} & \multicolumn{2}{c|}{Compatibility}\\
|
||||
\cline{2-3}
|
||||
& Front Coupler & Rear Coupler\\\hline
|
||||
\begin{tabularx}{\textwidth}{X c c}
|
||||
\toprule
|
||||
\multirow[t]{2}{*}{\bfseries Coupler Type} & \multicolumn{2}{c}{\bfseries Compatibility}\\
|
||||
\cmidrule(lr){2-3}
|
||||
& {\bfseries Front Coupler} & {\bfseries Rear Coupler}\\\midrule
|
||||
]])
|
||||
if not lcouplers[1] then
|
||||
lcouplers = {[[\textemdash]]}
|
||||
lcouplers = {[[Default]]}
|
||||
end
|
||||
for i = 1, #lcouplers do
|
||||
local cdesc = lcouplers[i]
|
||||
local cid = couplerid[cdesc]
|
||||
local fd, rd = "", ""
|
||||
if flim then
|
||||
fd = fcouplers[cid] and "Supported" or "Unsupported"
|
||||
fd = fcouplers[cid] and [[$\bullet$]] or ""
|
||||
elseif i == 1 then
|
||||
fd = fcouplers and "N/A" or "Universal"
|
||||
fd = string.format([[\multirow{%d}{*}{%s}]], #lcouplers, fd)
|
||||
fd = fcouplers and "" or "Universal"
|
||||
fd = string.format([[\multirow[t]{%d}{*}{%s}]], #lcouplers, fd)
|
||||
end
|
||||
if rlim then
|
||||
rd = rcouplers[cid] and "Supported" or "Unsupported"
|
||||
rd = rcouplers[cid] and [[$\bullet$]] or ""
|
||||
elseif i == 1 then
|
||||
rd = rcouplers and "N/A" or "Universal"
|
||||
rd = string.format([[\multirow{%d}{*}{%s}]], #lcouplers, rd)
|
||||
rd = rcouplers and "" or "Universal"
|
||||
rd = string.format([[\multirow[t]{%d}{*}{%s}]], #lcouplers, rd)
|
||||
end
|
||||
table.insert(st, string.format([[%s&%s&%s\\\hline]], cdesc, fd, rd))
|
||||
table.insert(st, string.format([[%s&%s&%s\\]], cdesc, fd, rd))
|
||||
end
|
||||
table.insert(st, [[\bottomrule]])
|
||||
table.insert(st, [[\end{tabularx}]])
|
||||
end
|
||||
|
||||
@ -427,25 +417,27 @@ function advtrains_doc_integration.write_wagon_info_as_latex(itemname)
|
||||
table.insert(st, [[\section{Wagon Capacity}]])
|
||||
if hasseats then
|
||||
table.insert(st, [[
|
||||
\begin{tabularx}{\textwidth}{|X|c|c|}
|
||||
\hline
|
||||
Seat Group & Driver Stand & Seat Count\\\hline
|
||||
\begin{tabularx}{\textwidth}{X c c}
|
||||
\toprule
|
||||
{\bfseries Seat Group} & {\bfseries Driver Stand} & {\bfseries Seat Count}\\\midrule
|
||||
]])
|
||||
for _, d in pairs(prototype.seat_groups) do
|
||||
table.insert(st, string.format([[%s & %s & %d\\\hline]], SL(d.name), d.driving_ctrl_access and "Yes" or "No", d.count))
|
||||
table.insert(st, string.format([[%s & %s & %d\\]], SL(d.name), d.driving_ctrl_access and [[$\bullet$]] or "", d.count))
|
||||
end
|
||||
table.insert(st, [[\bottomrule]])
|
||||
table.insert(st, [[\end{tabularx}]])
|
||||
end
|
||||
if hasinv then
|
||||
if next(prototype.inventory_list_sizes or {}) ~= nil then
|
||||
table.insert(st, [[
|
||||
\begin{tabularx}{\textwidth}{|X|c|}
|
||||
\hline
|
||||
Inventory Name & Capacity\\\hline
|
||||
\begin{tabularx}{\textwidth}{X c}
|
||||
\toprule
|
||||
{\bfseries Inventory Name} & {\bfseries Capacity}\\\midrule
|
||||
]])
|
||||
for k, v in pairs(prototype.inventory_list_sizes) do
|
||||
table.insert(st, string.format([[\texttt{%s} & %d\\\hline]], SL(k), v))
|
||||
table.insert(st, string.format([[\texttt{%s} & %d\\]], SL(k), v))
|
||||
end
|
||||
table.insert(st, [[\bottomrule]])
|
||||
table.insert(st, [[\end{tabularx}]])
|
||||
else
|
||||
table.insert(st, [[This wagon has an inventory of unknown size.]])
|
||||
|
Loading…
x
Reference in New Issue
Block a user