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. :)
Related
I am trying to produce some plots in latex using pgfplots; because of the fact that I have several different plots to produce, I am trying to use a for loop. Unfortunately, without success. Indeed, the code is executed three times but the value of the variable of the for loop it is always equal to the first value of the list that defines the loop.
For example, the following minimal code
\documentclass[a4paper, 11pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\usepgfplotslibrary{groupplots}
\begin{document}
\makeatletter
\begin{tikzpicture}
\begin{groupplot}[group style={group size= 2 by 3}]
\#for\refin:={1,2,3}\do{%
\nextgroupplot[ylabel={$h = \frac{1}{\refin}$}]
\addplot {exp(x)};
\nextgroupplot
\addplot{2 * x};
}
\end{groupplot}
\end{tikzpicture}
\makeatother
\end{document}
Produces a figure with 6 plots (as expected) but the label is always 1/1 and never 1/2 or 1/3. Why?
You can use the same trick as https://tex.stackexchange.com/a/539754/36296 :
\documentclass[a4paper, 11pt]{article}
\usepackage{pgffor}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\usepgfplotslibrary{groupplots}
\begin{document}
\begin{tikzpicture}
\begin{groupplot}[group style={group size= 2 by 3}]
\pgfplotsforeachungrouped \x in {1,2,3}{
\edef\tmp{
\noexpand\nextgroupplot[ylabel={$h = \frac{1}{\x}$}]
\noexpand\addplot {exp(x)};
}
\tmp
\nextgroupplot
\addplot{2 * x};
}
\end{groupplot}
\end{tikzpicture}
\end{document}
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.
I have read a lot about the pain of replicate the easy robust option from STATA to R to use robust standard errors. I replicated following approaches: StackExchange and Economic Theory Blog. They work but the problem I face is, if I want to print my results using the stargazer function (this prints the .tex code for Latex files).
Here is the illustration to my problem:
reg1 <-lm(rev~id + source + listed + country , data=data2_rev)
stargazer(reg1)
This prints the R output as .tex code (non-robust SE) If i want to use robust SE, i can do it with the sandwich package as follow:
vcov <- vcovHC(reg1, "HC1")
if I now use stargazer(vcov) only the output of the vcovHC function is printed and not the regression output itself.
With the package lmtest() it is possible to print at least the estimator, but not the observations, R2, adj. R2, Residual, Residual St.Error and the F-Statistics.
lmtest::coeftest(reg1, vcov. = sandwich::vcovHC(reg1, type = 'HC1'))
This gives the following output:
t test of coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -2.54923 6.85521 -0.3719 0.710611
id 0.39634 0.12376 3.2026 0.001722 **
source 1.48164 4.20183 0.3526 0.724960
country -4.00398 4.00256 -1.0004 0.319041
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
How can I add or get an output with the following parameters as well?
Residual standard error: 17.43 on 127 degrees of freedom
Multiple R-squared: 0.09676, Adjusted R-squared: 0.07543
F-statistic: 4.535 on 3 and 127 DF, p-value: 0.00469
Did anybody face the same problem and can help me out?
How can I use robust standard errors in the lm function and apply the stargazer function?
You already calculated robust standard errors, and there's an easy way to include it in the stargazeroutput:
library("sandwich")
library("plm")
library("stargazer")
data("Produc", package = "plm")
# Regression
model <- plm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp,
data = Produc,
index = c("state","year"),
method="pooling")
# Adjust standard errors
cov1 <- vcovHC(model, type = "HC1")
robust_se <- sqrt(diag(cov1))
# Stargazer output (with and without RSE)
stargazer(model, model, type = "text",
se = list(NULL, robust_se))
Solution found here: https://www.jakeruss.com/cheatsheets/stargazer/#robust-standard-errors-replicating-statas-robust-option
Update I'm not so much into F-Tests. People are discussing those issues, e.g. https://stats.stackexchange.com/questions/93787/f-test-formula-under-robust-standard-error
When you follow http://www3.grips.ac.jp/~yamanota/Lecture_Note_9_Heteroskedasticity
"A heteroskedasticity-robust t statistic can be obtained by dividing an OSL estimator by its robust standard error (for zero null hypotheses). The usual F-statistic, however, is invalid. Instead, we need to use the heteroskedasticity-robust Wald statistic."
and use a Wald statistic here?
This is a fairly simple solution using coeftest:
reg1 <-lm(rev~id + source + listed + country , data=data2_rev)
cl_robust <- coeftest(reg1, vcov = vcovCL, type = "HC1", cluster = ~
country)
se_robust <- cl_robust[, 2]
stargazer(reg1, reg1, cl_robust, se = list(NULL, se_robust, NULL))
Note that I only included cl_robust in the output as a verification that the results are identical.
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.
I tried it using the commented out code without success. Can somebody help?
\documentclass[a4paper]{article}
%\usepackage[english,greek]{babel}
%\latintext
\title{Sweave Example 1}
\author{George Dontas}
\begin{document}
\maketitle
In this example we embed parts of the examples from the
\texttt{kruskal.test} help page into a \LaTeX{} document:
%\greektext
Αυτό είναι κείμενο στα Ελληνικά
%\latintext
<<eval=TRUE,echo=TRUE,warning=FALSE,message=FALSE,error=FALSE>>=
data(airquality)
kruskal.test(Ozone ~ Month, data = airquality)
#
which shows that the location parameter of the Ozone distribution varies significantly from month to month. Finally we
include a boxplot of the data:
\begin{center}
<<eval=TRUE,echo=FALSE,results='hide',warning=FALSE,message=FALSE,error=FALSE>>=
boxplot(Ozone ~ Month, data = airquality)
#
\end{center}
\end{document}
The problem here is not the R but matter of getting latex to play well with Greek. With hat tip to this answer, perhaps the easiest solution is to switch to XeLaTeX compilation and rewrite your file as
\documentclass[a4paper]{article}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\setsansfont{Arial}
\newfontfamily\greekfont[Script=Greek]{Linux Libertine O}
\newfontfamily\greekfontsf[Script=Greek]{Linux Libertine O}
\usepackage{polyglossia}
\setdefaultlanguage{english}
\setotherlanguage{greek}
\title{Sweave Example 1}
\author{George Dontas}
\begin{document}
\maketitle
Ελληνικό κείμενο
In this example we embed parts of the examples from the
\texttt{kruskal.test} help page into a \LaTeX{} document:
...
and so on as before. Then compile with XeLaTeX (latexmk -xelatex file.Rnw will do that).