Table labeling and referencing in Rmarkdown - reference
I'm using markdown to render in PDF format.
I am able to cross-reference plot, but when I build a table in LaTeX, I can't do it somehow. An example:
We plot in Figure \#ref(fig:plotseries) the three Index series and their log return series. In Table \#ref(tab:summindex_stargazer) the main characteristics...
while the table has been coded as follow:
\begin{table}[!htbp] \centering
\caption[Summary statistics for token indexes under study.]{Summary statistics for large cap (L.MWI), medium cap (M.MWI), and small cap (S.MWI) indexes log return series. \label{tab:summindex_stargazer}}
\footnotesize
\begin{tabular}{#{\extracolsep{5pt}} cccc}
\\[-1.8ex]\hline
\hline \\[-1.8ex]
& L.MWI Returns & M.MWI Returns & S.MWI Returns \\
\hline \\[-1.8ex]
nobs & $1,524$ & $1,380$ & $1,362$ \\
NAs & $0$ & $0$ & $0$ \\
Minimum & $-0.351$ & $-0.549$ & $-0.933$ \\
Maximum & $0.464$ & $0.699$ & $1.010$ \\
1. Quartile & $-0.031$ & $-0.034$ & $-0.052$ \\
3. Quartile & $0.036$ & $0.039$ & $0.050$ \\
Mean & $0.003$ & $0.004$ & $0.002$ \\
Median & $0.002$ & $0.004$ & $-0.003$ \\
Sum & $4.144$ & $5.333$ & $2.863$ \\
SE Mean & $0.002$ & $0.002$ & $0.004$ \\
LCL Mean & $-0.001$ & $0.000$ & $-0.005$ \\
UCL Mean & $0.006$ & $0.008$ & $0.009$ \\
Variance & $0.004$ & $0.005$ & $0.017$ \\
Stdev & $0.066$ & $0.073$ & $0.130$ \\
Skewness & $0.236$ & $0.214$ & $1.000$ \\
Kurtosis & $4.355$ & $11.602$ & $13.393$ \\
\hline \\[-1.8ex]
\end{tabular}
\end{table}
This is the result.
Found out the solution. Basically you are not allowed to use “underscore”(_) in table labels.
It was so simple but also so incredibly hard to find out (I personally know many people who’d encountered this error and were not able to solve it). I hope it will help.
Adding to what is written here, underscores are one of 10 special characters in LaTeX.
For underscores to be permitted in table labels they need to be escaped.
This should work:
\#ref(tab:summindex\_stargazer)
But not this:
\#ref(tab:summindex_stargazer)
See this discussion for an excellent reference on special characters.
Related
Dynamic Title (Card Visual) based on SelectedValue
I try to implement a dynamic title (card visual) based on selectedValues of filters. I have tried this: Title = SWITCH( True(); SELECTEDVALUE(Daten[Contact Name]); "Aufgaben von " & SELECTEDVALUE(Daten[Contact Name]); SELECTEDVALUE(Daten[Buchungs Datum].[Year]); "Aufgaben vom Jahr " & SELECTEDVALUE(Daten[Buchungs Datum].[Year]); SELECTEDVALUE(Daten[Verkäufer]); "Aufgaben von Verkäufer: " & SELECTEDVALUE(Daten[Verkäufer]); SELECTEDVALUE(Daten[Contact Name]) & SELECTEDVALUE(Daten[Buchungs Datum].[Year]); "Aufgaben von " &SELECTEDVALUE(Daten[Contact Name]) & " vom Jahr " & SELECTEDVALUE(Daten[Buchungs Datum].[Year]); SELECTEDVALUE(Daten[Buchungs Datum].[Year]) & SELECTEDVALUE(Daten[Verkäufer]); "Aufgaben vom Jahr " & SELECTEDVALUE(Daten[Buchungs Datum].[Year]) & " vom Verkäufer: " & SELECTEDVALUE(Daten[Verkäufer]) ) I try to catch each possibilities of the applied filters. Bases on the applied filters the title card will dynamically change. True doesn't work witch cases of type selectedvalue. Which makes sence, but now i dont know really how to get the result i want. Is there any suggestion how I could implement this measure differently? Thank you.
If I got it right you are trying to return a string, based on the current selections made by the user. "SELECTEDVALUE()" returns the column value if there is only one value selected, otherwise an optional default value. The returned value is the column value itself (number/string/date) whatever the column contains, not strictly true/false. In order to make it work, you may want to use "HASONEVALUE()" which returns what you need Title = SWITCH( True(); HASONEVALUE(Daten[Contact Name]) && HASONEVALUE(Daten[Buchungs Datum].[Year]); "Aufgaben von " & SELECTEDVALUE(Daten[Contact Name]) & " vom Jahr " & SELECTEDVALUE(Daten[Buchungs Datum].[Year]); HASONEVALUE(Daten[Buchungs Datum].[Year]) && HASONEVALUE(Daten[Verkäufer]); "Aufgaben vom Jahr " & SELECTEDVALUE(Daten[Buchungs Datum].[Year]) & " vom Verkäufer: " & SELECTEDVALUE(Daten[Verkäufer]); HASONEVALUE(Daten[Contact Name]); "Aufgaben von " & SELECTEDVALUE(Daten[Contact Name]); HASONEVALUE(Daten[Buchungs Datum].[Year]); "Aufgaben vom Jahr " & SELECTEDVALUE(Daten[Buchungs Datum].[Year]); HASONEVALUE(Daten[Verkäufer]); "Aufgaben von Verkäufer: " & SELECTEDVALUE(Daten[Verkäufer]) ) Also, the AND operator (used in the last two cases) is "&&", not "&". You may improve the readability of this expression by using some variables, especially if the formula will get longer. Edit: The most restrictive expressions must be at the top, otherwise, a less restrictive condition will be triggered. ie: HASONEVALUE(Daten[Contact Name]) && HASONEVALUE(Daten[Buchungs Datum].[Year]) -- since this a "subset" of the previous one, it will be true in the same moment. -- if it's evaluated before the other one (in the switch) then the other will never be evaluated HASONEVALUE(Daten[Contact Name])
How to insert a table in TikzEdt? (Create Tikz diagrams with tables using a GUI)
I'm trying to find the easiest way to create Tikz diagrams mixed with tables. Such as these: or https://tex.stackexchange.com/questions/400557/how-to-add-connected-graphs-to-a-table Writing properly all this code can become quite complex and prone to error. There are several tools to help you create TikZ diagrams, such as TikzEdt. One could try to create TikZ diagrams with that tools and import them to your main tex document. But it will be difficult to make a complex diagram properly match the text, tables and other figures. An alternative would be to create the tables with Lyx, and import it from TikzEdt to start drawing above it. I've tried inserting the table code in the preample (TikzEdt) or in its main code window but I haven't been able to get it. In its settings -> compiler options it has this code: \documentclass{article} \usepackage{tikz,amsmath, amssymb,bm,color} \usepackage[margin=0cm,nohead]{geometry} \usepackage[active,tightpage]{preview} \usetikzlibrary{shapes,arrows} % needed for BB \usetikzlibrary{calc} Imagine I want to add this table: \documentclass{article} \begin{document} \begin{tabular}{ccc} ID & Ord & Event\\ \hline Ana & 1 & A\\ Tom & 1 & A\\ Tom & 2 & B\\ Tom & 3 & D\\ \end{tabular} \end{document} I've tried modyfing the code as: \documentclass{article} \usepackage{tikz,amsmath, amssymb,bm,color} \usepackage[margin=0cm,nohead]{geometry} \usepackage[active,tightpage]{preview} \usetikzlibrary{shapes,arrows} % needed for BB \usetikzlibrary{calc} \begin{document} \begin{tabular}{ccc} ID & Ord & Event\\ \hline Ana & 1 & A\\ Tom & 1 & A\\ Tom & 2 & B\\ Tom & 3 & D\\ \end{tabular} \end{document} but it doesn't produce any result. I guess because it tries to add a begin{document} twice. I've also tried leaving the preamble as is and adding the table on the main window. \begin{tabular}{ccc} ID & Ord & Event\\ \hline Ana & 1 & A\\ Tom & 1 & A\\ Tom & 2 & B\\ Tom & 3 & D\\ \end{tabular} \begin{tikzpicture} \end{tikzpicture} But again it doesn't work. How can I do it? Or what other GUI tool can I use able to draw TikZ arrows and simple symbols onto a preexistent document or able to create tables?
I was looking for a solution of the same problem and found this very useful link! It contains the following code: \begin{tikzpicture} \matrix[ampersand replacement=\&] { \node (species1) [shape=rectangle,draw] { \begin{tabular}{c c c} \multicolumn{3}{c}{{Species 1}} \\ \colorbox{red}{G1t} & \colorbox{blue}{G2a} & \colorbox{green}{G3t} \\ \colorbox{blue}{G1b} & \colorbox{red}{G2b} & \end{tabular} }; \& \node {b}; \\ \node {c}; \& \node {d}; \\ }; \end{tikzpicture} I've just tried it myself, and it does what it says on the tin: it lets you use tabular inside a tikz node. No extra packages or other things to be included in the header. You could then move the node around and use it to make diagrams like you wanted.
LaTeX table positioning at specific point in code
I try to keep the following table at the same position as it appears in my LaTeX code. \begin{table*}[h] \makebox[\linewidth]{ \begin{tabular}{| c | c | c |} \hline Datum & [Tage] & [Tage]\\ \hline 01.03.2010 & 1 nach \fullmoon & 5 bis \leftmoon\\ 15.03.2010 & \multicolumn{2}{c|}{\newmoon}\\ 10.12.2009 & 1 nach \leftmoon & 6 vor \newmoon\\ 09.03.2009 & 5 nach \rightmoon & 2 vor \fullmoon\\ 07.01.2010 & \multicolumn{2}{c|}{\leftmoon}\\ 14.12.2010 & 1 nach \rightmoon & 7 vor \fullmoon\\ 02.04.2009 & \multicolumn{2}{c|}{\rightmoon}\\ \hline \end{tabular} } \caption{Niedrigste relative Intensität. \fullmoon Vollmond, \newmoon Neumond, \rightmoon{} zunehmender Halbmond, \leftmoon abnehmender Halbmond} \label{table10} \end{table*} So I tried it with [H], but this lets the table disappear. Also trying something from another thread \usepackage{float} \restylefloat{table} does not work. Any advice ?
If there's enough space at that point of the output page to accommodate that table, then this couple of tweaks should probably do: change {table*} to {table} change [h] to [h!] The \makebox{...} environment should also be done away with to avoid complications. If LaTeX isn't able to place the table at that point, it gives a warning, but the table should never disappear, then.
currency conversion:number to words excel
I would like to convert the the Kuwait currency which has three decimal places into words in an Excel Document.The formula i used is as follows: =if(or(isBlank($E$89),not(isNumber($E$89)),$E$89>=power(10,15)),ifError(1/0),trim(arrayFormula(concatenate(if(trunc(mod($E$89,power(10,15,12,9,6,3}))/power(10,{12,9,6,3,0}))<100,"",switch(int(trunc(mod($E$89,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0}))/100),1," one",2," two",3," three",4," four",5," five",6," six",7," seven",8," eight",9," nine") & " hundred") & if(mod(trunc(mod($E$89,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0})),100)<>0,if(trunc(mod($E$89,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0}))>100," and",if($E$89>power(10,{15,12,9,6,3}),switch({1,2,3,4,5},5," and"),"")),"") & if(mod(trunc(mod($E$89,power(10,{15,12,9,6,3}))/power(10,12,9,6,3,0})),100)=0,"",if(mod(trunc(mod($E$89,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0})),100)<20,IFERROR(switch(mod(trunc(mod($E$89,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0})),100),1," one",2," two",3," three",4," four",5," five",6," six",7," seven",8," eight",9," nine",10," ten",11," eleven",12," twelve",13," thirteen",14," fourteen",15," fifteen",16," sixteen",17," seventeen",18," eighteen",19," nineteen")),IFERROR(switch(int(mod(trunc(mod($E$89,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0})),100)/10),2," twenty",3," thirty",4," forty",5," fifty",6," sixty",7," seventy",8," eighty",9," ninety")) & if(mod(mod(trunc(mod($E$89,power(10,{15,12,9,6,3}))/power(10,12,9,6,3,0})),100),10)=0,"","-" & IFERROR(switch(mod(mod(trunc(mod($E$89,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0})),100),10),1,"one",2,"two",3,"three",4,"four",5,"five",6,"six",7,"seven",8,"eight",9,"nine"))))) & if(trunc(mod($E$89,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0}))=0,"",IFERROR(switch({1,2,3,4,5},1," trillion",2," billion",3," million",4," thousand"))))) & if($E$89>=2," Dinar only",if($E$89>=1," Dinar only","")) & if((round($E$89-trunc($E$89),3)*1000=0)+($E$89<1),""," and") & switch(trunc(round($E$89-trunc($E$89),3)*1000,-2)/100,1," one-hundred",2," two",3,-hundred" three-hundred",4," four-hundred",5," five-hundred",6," six-hundred",7," seven-hundred",8," eight-hundred",9," nine-hundred"& if(round($E$89-trunc($E$89),3)*1000-trunc(round($E$89-trunc($E$89),3)*1000,-2)<20,switch(round($E$89-trunc($E$89),3)*1000-trunc(round($E$89-trunc($E$89),3)*1000,-1),0,"",1," one",2," two",3," three",4," four",5," five",6," six",7," seven",8," eight",9," nine",10," ten",11," eleven",12," twelve",13," thirteen",14," fourteen",15," fifteen",16," sixteen",17," seventeen",18," eighteen",19," nineteen"),switch((round($E$89-trunc($E$89),3)*1000-trunc(round($E$89-trunc($E$89),3)*1000,-2))/10,2," twenty",3," thirty",4," forty",5," fifty",6," sixty",7," seventy",8," eighty",9," ninety") & if(mod(round($E$89-trunc($E$89),3)*1000,10)=0,"","-" & switch(round($E$89-trunc($E$89),3)*1000-trunc(round($E$89-trunc($E$89),3)*1000,-1),0"",1,"one",2,"two",3,"three",4,"four",5,"five",6,"six",7,"seven",8,"eight",9,"nine"))) & " fils only"))) The error shown is Formula parse error For a given input: 111.250 i would expect to get the output as : One hundred and eleven Dinar and two hundred fifty fils only.
Try looking for JavaScript solutions to use then as custom function. I've found is this code, provided by #Vilas Shetkar: https://stackoverflow.com/a/37409158/5372400 I've tested this code and it works in sheets, so you may adopt this or other similar solutions to your needs.
Excel Amount in Words Formula
I found this formula below to convert amounts to words for google spreadsheets and it works perfectly. But now I want to use it in excel 2010 and I get a lot of errors. I also cannot use VBA. Thanks for any help. =if(or(isBlank(A1),not(isNumber(A1)),A1>=power(10,15)),ifError(1/0,"Error"),trim(arrayFormula(concatenate(if(trunc(mod(A1,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0}))<100,"",choose(int(trunc(mod(A1,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0}))/100)," One"," Two"," Three"," Four"," Five"," Six"," Seven"," Eight"," Nine") & " Hundred") & if(mod(trunc(mod(A1,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0})),100)<>0,if(trunc(mod(A1,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0}))>100," And",if(A1>power(10,{15,12,9,6,3}),choose({1,2,3,4,5},"","","",""," And"),"")),"") & if(mod(trunc(mod(A1,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0})),100)=0,"",if(mod(trunc(mod(A1,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0})),100)<20,choose(mod(trunc(mod(A1,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0})),100)," One"," Two"," Three"," Four"," Five"," Six"," Seven"," Eight"," Nine"," Ten"," Eleven"," Twelve"," Thirteen"," Fourteen"," Fifteen"," Sixteen"," Seventeen"," Eighteen"," Nineteen"),choose(int(mod(trunc(mod(A1,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0})),100)/10),""," Twenty"," Thirty"," Forty"," Fifty"," Sixty"," Seventy"," Eighty"," Ninety") & if(mod(mod(trunc(mod(A1,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0})),100),10)=0,"","-" & choose(mod(mod(trunc(mod(A1,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0})),100),10),"One","Two","Three","Four","Five","Six","Seven","Eight","Nine")))) & if(trunc(mod(A1,power(10,{15,12,9,6,3}))/power(10,{12,9,6,3,0}))=0,"",choose({1,2,3,4,5}," Trillion"," Billion"," Million"," Thousand","")))) & if(A1>=2," Rand",if(A1>=1," Rand","")) & if((round(A1-trunc(A1),2)*100=0)+(A1<1),""," And") & if(round(A1-trunc(A1),2)*100=0,"",if(round(A1-trunc(A1),2)*100=1," One Cent",if(round(A1-trunc(A1),2)*100<20,choose(round(A1-trunc(A1),2)*100," One"," Two"," Three"," Four"," Five"," Six"," Seven"," Eight"," Nine"," Ten"," Eleven"," Twelve"," Thirteen"," Fourteen"," Fifteen"," Sixteen"," Seventeen"," Eighteen"," Nineteen"),choose(int(round(A1-trunc(A1),2)*100/10),""," Twenty"," Thirty"," Forty"," Fifty"," Sixty"," Seventy"," Eighty"," Ninety") & if(mod(round(A1-trunc(A1),2)*100,10)=0,"","-" & choose(mod(round(A1-trunc(A1),2)*100,10),"One","Two","Three","Four","Five","Six","Seven","Eight","Nine"))) & " Cent"))))
If your numbers do not need to go above ~100, it may be easier to make two columns, the first with the 1,2,3 etc. and the second with one,two,three etc. Then you can do VLOOKUP() on that table. An example can be found here: https://www.dropbox.com/s/e44dnkg3he8b8il/NumericalToAlpha.xlsx