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}
Related
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}
Hi I'm new to latex I use here the Algorithmic package to write my pseudo code the problem I faced is that 'some text' is displayed correctly under the second loop but the 'return' statement which needs to be outside the first for loop isn't showing correctly also it does not mark the end of each loop (the vertical tic is missing), the execution result is shown in the image:
\documentclass{article}
\usepackage[utf8,linesnumbered,ruled,vlined]{algorithm2e}
\usepackage {algpseudocode}
\usepackage{algorithmicx}
\usepackage{algcompatible}
\begin{document}
\begin{algorithm}
\ContinuedFloat
\caption{My algorithm}
\textbf{Input:} solution,bound, data\_matrix, vehicle\_capacity, demand\_data,k\_max,operations\_data, move\_type,tenure, max\_number\_of\_moves,max\_iter,non\_improvement\_maxiter,itermax,epsilon\\
\textbf{Output:} $best$ $solution$ \\[0.1in]
routes = extract routes from \textbf{solution}\\
oldfitness = fitness(\textbf{solution})\\
ls\_move\_type = inversion\\
best\_solution = routes\\[0.1in]
\For{0 \leq i \leq itermax}{
new\_routes = [ ]\\
desc = 'normal route'\\
\For{route \textbf{in} routes}{
n=length(route)\\
comb = int($\frac{n!}{(n-2)!}$)\\
\If{n \geq 4}{
tabu\_list\_tenure = $\frac{comb}{5}$\\
ls\_maxiteration = 50 \\
ls\_move\_type = 'inversion'\\
}
\If{3 \leq n \leq 4}{
tabu\_list_tenure = $\frac{comb}{4}$ \\
ls\_maxiteration = 25\\
ls\_move\_type = 'relocation'\\
}
\Else{
append \textbf{route} to \textbf{new\_routes}\\
desc = 'short route'\\
}\\[0.1in]
}
some action
}
return
\end{algorithm}
\end{document}
There is no point in wondering about the output as long as you get errors in your .log file. After an error, latex only recovers enough to syntax check the rest of the document, not necessarily producing sensible output.
Some of the most critical problems:
never ignore error messages!
utf8 isn't a valid option for the algorithm2e package
\ContinuedFloat is not defined by default. If you want to use it, you need a package which defines it. Maybe you want to use the caption package?
never ever use math mode to fake italic text as in $best$ $solution$. This completely messes up the kerning
some of your _ are not escaped
you mustn't use math commands like 0 \leq i \leq outside of math mode
use something like \Return to properly format it
using \\ for line breaks is already quite questionable, but using them two times in a row is simply an error.
because one can't say it often enough: never ignore error messages!
\documentclass{article}
\usepackage[
%utf8,
linesnumbered,ruled,vlined]{algorithm2e}
\usepackage {algpseudocode}
\usepackage{algorithmicx}
\usepackage{algcompatible}
\begin{document}
\begin{algorithm}
%\ContinuedFloat
\caption{My algorithm}
\textbf{Input:} solution,bound, data\_matrix, vehicle\_capacity, demand\_data,k\_max,operations\_data, move\_type,tenure, max\_number\_of\_moves,max\_iter,non\_improvement\_maxiter,itermax,epsilon
\textbf{Output:} \emph{best solution}
\medskip
routes = extract routes from \textbf{solution}
oldfitness = fitness(\textbf{solution})
ls\_move\_type = inversion
best\_solution = routes
\medskip
\For{$0 \leq i \leq$ itermax}{
new\_routes = [ ]
desc = 'normal route'
\For{route \textbf{in} routes}{
n=length(route)
comb = int($\frac{n!}{(n-2)!}$)
\If{$n \geq 4$}{
tabu\_list\_tenure = $\frac{comb}{5}$
ls\_maxiteration = 50
ls\_move\_type = 'inversion'
}
\If{$3 \leq n \leq 4$}{
tabu\_list\_tenure = $\frac{comb}{4}$
ls\_maxiteration = 25
ls\_move\_type = 'relocation'
}
\Else{
append \textbf{route} to \textbf{new\_routes}
desc = 'short route'
}
\medskip
}
some action
}
\Return
\end{algorithm}
\end{document}
I am working on a protocol using TeXMaker. I switched from Eclipse+Texlipse to Texmaker and what compiled successfully before, does not compile anymore.
I have a main.tex file, which contains the structure of my protocol. I have several tex-files as inputs and a design.sty, which provides my design. I want to compile and create the PDF-protocol.
When I try to execute the following code in TeXMaker (the main.tex):
\documentclass[11pt,a4paper,oneside,listof=totoc, bibliography=totoc
version=first]{scrreprt}
\usepackage{design}
\begin{document}
\pagenumbering{arabic}
% cover
\input{./cover.tex}
% introduction
\newpage
\chapter{Introduction}
\section{Synmikro}
\input{./synmicro.tex}
\section{Genetic Switches}
\input{./switches.tex}
\section{ECFs}
\input{./ECF.tex}
\section{Sinorhizobium Meliloti}
\input{./meliloti.tex}
\newpage
\section{Laboratory Internship}
\input{./internship.tex}
\section{Bioinformatics}
\input{./bioinfo.tex}
% materials and methods
\newpage
\chapter{Material and Methods}
\section{Used strains}
\input{./MMexoECFs.tex}
\section{Cultivation conditions}
\input{./MMcultivation.tex}
\section{RNA preparation}
\input{./MMrNAprep.tex}
\section{Quality control of total RNA}
\input{./MMtotalRNAQC.tex}
%\section{Quality control}
% \subsection{PCR and Agarose gel}
% \input{./MMnormPCR.tex}
%\subsection{RNA purity and integrity control}
% \input{./MMbioanalyzer.tex}
\section{qRT-PCR}
\input{./MMqRTPCR.tex}
%\section{QBit}
% \input{./MMqbit.tex}
\section{Bioinformatics}
\input{./MMbioinfo.tex}
\subsection{Non-restrictive approach}
\input{./MMnonRestrictive.tex}
\subsection{Levenshtein distance}
\input{./MMlev2.tex}
\subsection{Feature Search}
\input{./MMfeatureSearch.tex}
%\subsection{Position Specific Scoring Matrices}
% \input{./MMpssm.tex}
% results
\newpage
\chapter{Results}
%\section{Agarose Gel}
% \input{./Ragarose.tex}
\section{Nanodrop and Bioanalyzer}
\input{./Rbioanalyzer.tex}
%\section{Qbit}
% \input{./Rqubit.tex}
\newpage
\section{Real-Time PCR}
\input{./RRTpCR.tex}
\newpage
\section{Bioinformatics}
\input{./Rbioinfo.tex}
% discussion
\end{document}
TeXMaker gives me several errors for main.tex. They are:
Line 47: File ended while scanning use of \caption#xdblarg
Line 79: !Latex Error: \begin{figure} on input line 7 ended by \end{document}
Line 79: !You can't use '\end’ in internal vertical mode
Line 79: !Latex Error: \begin{figure} on input line 7 ended by \end{document}
! Missing } inserted
Line 1: ! Emergency stop. <*> main.tex ***(job aborted, no legal \end found)
Line 47 is "\input{./MMqRTPCR.tex}
Line 79 is "\end{document}"
I am honestly confused. TeXMaker's error description is about missing braces. Am I screen-blind? I checked the braces 3 times and cannot figure out, what I missed. So, I am guessing, I missed something crucial about Latex.
Thanks for any help!
UPDATE:
In the input file "MMqRTPCR.tex", I out-commented a figure and all errors are gone. Here is the content of the file.
TEXTEXTEXT
%\begin{figure}[H]
%\centering
% \includegraphics[scale=0.6,natwidth=764,natheight=218]%{deltaDeltaCorrectedFormula.png}
% \caption{mycaption}
%\label{deltaDelta}
%\end{figure}
TEXTEXTEXT
\begin{table}[!h]
\centering
\caption{Primer sequences and targets}
\label{table1}
\begin{tabular}{|l|l|l|ll}
\cline{1-3}
Primer Sequence & Target & Direction \\ \cline{1-3}
AACATGTGCCGGTTGATAG & ECF20_992 & forward \\ \cline{1-3}
GCTGCTTCGGTATTGCTCA & ECF20_992 & reverse \\ \cline{1-3}
TCGTACCATTGAAAGCCTG & ECF02_2817 & forward \\ \cline{1-3}
ATCAATGGCTTCACGTGCA & ECF02_2817 & reverse \\ \cline{1-3}
TTCAAGAAACCATGGCCAC & ECF11_987 & forward \\ \cline{1-3}
GCTCGGCCAAATATCATCG & ECF11_987 & reverse \\ \cline{1-3}
\end{tabular}
\end{table}
TEXTEXTEXT
** UPDATE & SOLUTION**
The error was not in the main.tex itself, but in an input file. So, when TeXMaker tells you about missing bracers, jump to the line, where the error occured in the main.tex and check the bracers in the input file, which you see there.
So,
the error was a missing curly brace after all! Yet, it was not missing in the main.tex, but in the input file within the figure caption!
Thanks anybody, who's brain might have melted trying to find a solution to my problem. I hope this helps others, if they encounter the same error. :)
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.
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.