\setmathfont command requires 2 minutes to compile with lualatex - time

This code takes 10 seconds to compile to a pdf. If I enable in the code the additional lines it takes 2 minutes to compile for the 5 lines. And this happens everytime.
Why does it take so long, and how can I prevent it?
The system is texlive on windows with latest packages:
This is LuaHBTeX, Version 1.15.0 (TeX Live 2022) (format=lualatex 2022.12.10) 17 DEC 2022 20:53
restricted system commands enabled.
LaTeX2e <2022-11-01> patch level 1
Lua module: luaotfload 2022-10-03 3.23 Lua based OpenType font support
This is the code
% !TeX encoding=utf8
% !TeX program = lualatex
\documentclass{article}
\usepackage{fontspec}
\usepackage{amsmath}
\usepackage{unicode-math}
\usepackage{tabularray}
\usepackage{xcolor}
\begin{document}
\newcommand{\fontstring}{Sphinx of black quartz, judge my vow.}
\newcommand{\mathstring}{$f(u,v) = \iiint \left[u\nabla^{2}v+\left(\nabla u,\nabla v\right)\right]\mathrm{d}^{3}V$}
\colorlet{tablerowcolor}{gray!10}
\colorlet{tablesubheadcolor}{azure3!30}
{ % start a group
\small\renewcommand{\arraystretch}{1.4}\sffamily
% the table
\begin{longtblr}[
caption = {Font examples},
label = {tab:doc:Font:Gallery}]
{
colspec = {X[1,l]>{\ttfamily}X[2,l]},
width = 1.0\textwidth,
row{odd} = {bg=tablerowcolor},
row{1} = {bg=azure3, fg=white, font=\sffamily\upshape},
rowhead = 1,
rowfoot = 0,
}
\hline % Table Header
Font & Example \\
\hline %
%
\SetCell[c=2]{l,bg=tablesubheadcolor} Latin Modern Family \\
Latin Modern Roman & \setmainfont{Latin Modern Roman} \rmfamily \fontstring \\
Latin Modern Sans & \setsansfont{Latin Modern Sans} \sffamily\fontstring \\
Latin Modern Mono & \setmonofont{Latin Modern Mono} \ttfamily \fontstring \\
%
\SetCell[c=2]{l,bg=tablesubheadcolor} Math Fonts \\
%
Latin Modern Math & \setmathfont{Latin Modern Math} \rmfamily \mathstring \\
% TeX Gyre Termes Math & \setmathfont{TeX Gyre Termes Math} \rmfamily \mathstring \\
% TeX Gyre Pagella Math & \setmathfont{TeX Gyre Pagella Math} \rmfamily \mathstring \\
% Charter - math version & \setmathfont{XCharter-Math.otf} \rmfamily \mathstring \\
% Garamond math version & \setmathfont{Garamond-Math} \rmfamily \mathstring \\
% Cambria Math & \setmathfont{Cambria Math} \rmfamily \mathstring \\
% %
\hline
%
\end{longtblr}
} % close the group
\end{document}

Related

How to print negative numbers within a parenthesis with spreadtab in LaTex

I am trying to produce financial statements with latex. An important convention of financial statements is that negative numbers are not presented with a negative sign, rather wrapped in parentheses, like this:
-100 -> (100)
The minimum necessary recreation of my issue is as follows:
\documentclass{report}
\usepackage{tabularx}
\usepackage{spreadtab}
\usepackage{numprint}
\npthousandsep{,}
\begin{document}
\begin{center}
\STautoround{0}
\begin{spreadtab}{{tabularx}{\linewidth}{XN{7}{0}N{7}{0}}}
#\multicolumn{3}{c}{\uppercase{Municipal Government}}\\
#\multicolumn{3}{c}{Statement of Net Position}\\
#\multicolumn{3}{c}{December 31, 2019}\\
&& \\
#\multicolumn{1}{c}{\uppercase{Assets}} & #\multicolumn{1}{c}{2019} & #\multicolumn{1}{c}{2018}\\
#\multicolumn{1}{c}{Current Assets}&&\\
# Cash & 12345 & 54321\\
# Receivables:&&\\
# \hspace{0.25in}Sewer Fees: & 12345 & 54321\\ \cline{2-3}
#\multicolumn{1}{r}{Total Current Assets} & sum(b7:[0,-1]) & sum(c7:[0,-1])\\ % r10
#\multicolumn{1}{c}{\uppercase{Fixed Assets}}&&\\
# Land & 12345 & 54321\\
# Garage & 99247 & 54321\\
# Equipment & 12345 & 54321\\
# Lagoon and Related & 12345 & 54321\\ \cline{2-3}
#\multicolumn{1}{r}{Total Fixed Assets} & sum(b12:[0,-1]) & sum(c12:[0,-1])\\ \cline{2-3} % r15
# Accumulated Depreciation & -12345 & -54321\\ \cline{2-3}
#\multicolumn{1}{r}{Net Fixed Assets} & sum(b16:[0,-1]) & sum(c16:[0,-1])\\ \cline{2-3}
#\multicolumn{1}{r}{Total Assets} & b18+b10 & c18+c10\\ \cline{2-3} \cline{2-3}
\end{spreadtab}
\end{center}
\end{document}
Where rather than Accumulated Depreciation -12345 -54321, it reads Accumulated Depreciation (12345) (54321).
I have found scant little information about it online, and I'm not entirely certain it's possible to do.
If at all possible, I would like to retain the decimal alignment while adding the parentheses. But again, I'm not sure it's possible.
A solution, below, was shared on StackOverflow several years ago, but it concludes in several errors which I am unsure how to move beyond: primarily the compiler complaining about dozens of "missing" or "extra" brackets.
\makeatletter
\renewcommand\STprintnum[1]{\FPifneg{#1}(\#gobble#1)\else#1\fi}
\makeatother
Update: Per the below answer, using SIunitx permits wrapping negative numbers in brackets, but this breaks the decimal alignment. A minimum working example of this is as follows:
\documentclass{report}
\usepackage{tabularx}
\usepackage{siunitx}
\usepackage{spreadtab}
\sisetup{group-separator = {,}}
\sisetup{bracket-negative-numbers = true}
\begin{document}
\begin{spreadtab}{{tabularx}{\linewidth}{XS[table-format=7.1]S[table-format=7.1]}}
# Fixed Assets & 123456.1 & 135791.1\\
# {Accumulated Depreciation} &-100000.1 &-90000.1\\ \cline{2-3}
#\multicolumn{1}{r}{Net Fixed Assets} & sum(b1:[0,-1]) & sum(c1:[0,-1])\\ \cline{2-3}
\end{spreadtab}
\end{document}
In the above example, the negative numbers are now offset in their alignment by the left and right parenthesis, so they cease to line up with the positive numbers.

How to fix wrong table labelling in Latex?

I am currently writing a report with many labels. All of them are working very well (section, figure, equations, ...) but not the labels of tables. Indeed, as I refer to any table, the pdf shows the label of the first table I defined...
I thought it may be due to one package I am using but I did not find out how to fix my issue.
\documentclass[a4paper,12pt,twoside,openright]{report}
\usepackage{array}
\usepackage{babel}
\usepackage{datatool}
\usepackage{environ}
\usepackage[T1]{fontenc}
\usepackage{fancyhdr}
\usepackage[top=0.5cm, bottom=0.5cm, left=2cm, right=2cm]{geometry}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage[
bookmarks = true,% % Signets
bookmarksnumbered = true,% % Signets numérotés%
bookmarksopen = true,% % Signets ouverts
colorlinks = true,% % Liens en couleur : true ou false
urlcolor = blue,% % Couleur des liens externes
linkcolor = black,% % Couleur des liens internes
citecolor = black,% % Couleur des citations
]{hyperref}%
\usepackage{ifthen}
\usepackage{indentfirst}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{bm}
\usepackage{makeidx}
\usepackage{stmaryrd}
\usepackage{tocbibind}
\usepackage{url}
\usepackage{pstricks}
\usepackage{xcolor}
\usepackage{placeins}
\begin{document}
\chapter{Table chapter}
\label{ch:table}
\section{Table section}
\label{sec:table}
\paragraph{}
Let's begin with Chapter~\ref{ch:table} and Section~\ref{sec:table}.
\paragraph{}
Here is Table~\ref{tab:success}.
\begin{table}[ht] \label{tab:success}
\centering
\begin{tabular}{|c|c|}
\hline
State & Success ? \\
\hline
Good & $\checkmark$ \\
\hline
\end{tabular}
\caption{Table of success.}
\end{table}
\begin{table}[ht] \label{tab:defeat}
\centering
\begin{tabular}{|c|c|}
\hline
State & Success ? \\
\hline
Bad & $\times$ \\
\hline
\end{tabular}
\caption{Table of defeat.}
\end{table}
\paragraph{}
But there is also Table~\ref{tab:defeat}.
\end{document}
The output is :
The output of the previous code
As you can see the second label is "1.1" and should be "1.2"...
What am I doing wrong?
Labels must never be before the caption -- they must be either after the caption or within the caption.
Unrelated to your problem, but hyperref should be loaded after the other packages (there are only a handful exceptions of packages which go after hyperref, e.g. cleveref)
\documentclass[a4paper,12pt,twoside,openright]{report}
\usepackage{array}
\usepackage{babel}
\usepackage{datatool}
\usepackage{environ}
\usepackage[T1]{fontenc}
\usepackage[top=0.5cm, bottom=0.5cm, left=2cm, right=2cm]{geometry}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{ifthen}
\usepackage{indentfirst}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{bm}
\usepackage{makeidx}
\usepackage{stmaryrd}
\usepackage{tocbibind}
\usepackage{url}
\usepackage{pstricks}
\usepackage{xcolor}
\usepackage{placeins}
\usepackage[
bookmarks = true,% % Signets
bookmarksnumbered = true,% % Signets numérotés%
bookmarksopen = true,% % Signets ouverts
colorlinks = true,% % Liens en couleur : true ou false
urlcolor = blue,% % Couleur des liens externes
linkcolor = black,% % Couleur des liens internes
citecolor = black,% % Couleur des citations
]{hyperref}%
\begin{document}
\chapter{Table chapter}
\label{ch:table}
\section{Table section}
\label{sec:table}
\paragraph{}
Let's begin with Chapter~\ref{ch:table} and Section~\ref{sec:table}.
\paragraph{}
Here is Table~\ref{tab:success}.
\begin{table}[ht]
\centering
\begin{tabular}{|c|c|}
\hline
State & Success ? \\
\hline
Good & $\checkmark$ \\
\hline
\end{tabular}
\caption{Table of success.}
\label{tab:success}
\end{table}
\begin{table}[ht]
\centering
\begin{tabular}{|c|c|}
\hline
State & Success ? \\
\hline
Bad & $\times$ \\
\hline
\end{tabular}
\caption{Table of defeat.}
\label{tab:defeat}
\end{table}
\paragraph{}
But there is also Table~\ref{tab:defeat}.
\end{document}

Eliminate matrix header in esttab (latex) or outtable output

I have a matrix of values (very non-standard summary statistics) that I want to pass from Stata to LaTeX. The command:
esttab matrix(matname) using $myfilename.tex, replace booktabs f
gives the matrix in LaTeX form but also gives the title of the matrix within the fragment. The same is true for:
outtable using myfilename, mat(matname) replace nobox
Currently, every time I rerun my Stata do file I have to go and edit myfilename.tex by hand.
Is there any way to non-manually remove the matrix name from the Stata to LaTeX output?
I tried using the option noheader, which works here:
matrix list matname, noheader
but doesn't seem to be active in esttab or outtable. It also occurred to me that if I could find a way to ask LaTex to just \input PART of the fragment file (lines 2 onward) that would work...
I think the nomtitles option will work. Here's reproducible example:
sysuse auto
reg price trunk headroom
matrix myMat = e(V)
esttab matrix(myMat) using temp.tex, replace booktabs f nomtitles
This produces the text (.tex) file below:
& trunk& headroom& \_cons\\
\midrule
trunk & 10557.96& -35339.31& -39464.18\\
headroom & -35339.31& 269901.5& -321726.7\\
\_cons & -39464.18& -321726.7& 1612951\\
Also, I used the following outtable command
outtable using "./temp", mat(myMat) replace center f(%9.2f) nobox
to produce this output:
% matrix: myMat file: ./temp.tex 10 Jun 2016 12:55:35
\begin{table}[htbp]
\begin{tabular}{lccc} \hline \hline
& trunk & headroom & cons \\ \hline
trunk & 10557.96 \\
headroom & -35339.31 & 269901.52 \\
cons & -39464.18 & -3.22e+05 & 1.61e+06 \\
\hline \hline \end{tabular}
\end{table}
While the matrix name is present in the output, it is commented out and so will not appear in the latex document.

forloop and table in LaTeX

Here is the LaTeX code for my table:
\begin{table}{| c || c | c | c || c | c | c | }
\caption{Examples of the concepts. \label{tab:conceptsimgs}}\\
\hline
\backslashbox{Concept}{Class} &\multicolumn{3}{|c||}{Negative Class} & \multicolumn{3}{|c|}{Positive Class} \\
\hline
\forloop{themenumber}{1}{\value{themenumber} < 4}{
%\hline
\arabic{themenumber}
\forloop{classnumber}{0}{\value{classnumber} < 2}{
\forloop{imagenumber}{1}{\value{imagenumber} < 4}{
& 0
}
}
\\
\hline
}
\end{table}
Something is wrong in the result however. There is some extra thing at the end of the table, as shown in here:
http://www. freeimagehosting. net/image.php?c702bfc838.png
How can I fix it?
That's a nasty one. I've created a minimal example that demonstrates the problem, see below. Try to compile this and take a look at the results.
The point is, you seem to be out of luck — tabular does not like the output of forloop, it cannot disregard the last \addtocounter command. Maybe you can find some other package for loops.
You should be able to figure out the rest from the code below, if not, write a comment.
\documentclass{article}
\usepackage{forloop}
\newcounter{themenumber}
\newcounter{test}
\begin{document}
% this is your table (minimal example)
\begin{tabular}{| c |}
\forloop{themenumber}{1}{\value{themenumber} < 2}{x\\ \hline}
\end{tabular}
\vspace{2cm}
% this is what you wanted to have
\begin{tabular}{| c |}
x \\ \hline
\end{tabular}
\vspace{2cm}
% this is what forloop produces
\begin{tabular}{| c |}
x \\ \hline \addtocounter{test}{1}
\end{tabular}
\end{document}

Rotated table in Latex appears at the end of the file

Any table I define with "sidewaystable" appears at the last page of created pdf file. How can I solve this?
\begin{sidewaystable}[h]
\caption{Blah Measurements}
\centering % centering table
\begin{tabular}{c c c c c c c c c c}
\hline\hline % inserting double-line
A & B & \multicolumn{3}{c}{C} & C Time + & D & \multicolumn{3}{c}{D Signal} \\
ID & ID & \multicolumn{3}{c}{Coordinates} & Time Diff. & Time & \multicolumn{3}{c}{Parameters} \\ [0.5ex]
\hline % inserts single-line
1 & 1 & 4415633.126837 & 482211.909079 & 939.450000 & 06:07:40 & 06:07:40 & -85 dBm & 6 dB & 5 dBm \\
\hline
\end{tabular}
\label{tab:combined}
\end{sidewaystable}
Have you tried the something like htbp for the placement of the float object?
\begin{sidewaystable}[htbp]
...
\end{sidewaystable}
Just use \clearpage \newpage before \begin{sidewaystable} and \clearpage after the \end{sidewaystable}..
It works without any floats like H, h!, htpb, etc.
you can try and use \begin{table}[h!] -- the ! will try and tell latex to force your table into the exact spot. I've had hit or miss results.
Also, with the float package, you can use a capital H \begin{table}[H] to keep your table from floating.

Resources