Referencing Figures in Latex - reference

I am currently writing my thesis in greek and whenever I try to reference a figure I get the following in my text:
[;;]
This is the code I wrote:
\begin{figure}[h]
\label{ fig:image1}
\includegraphics[width=1\textwidth]{image1}
\caption{Απεικόνιση τρόπου κληρονομικότητας}
\end{figure}
And I call the ref by writing: {\ref{fig:{image1}}.
How do I fix this?

There is a simple rule in latex \caption should always come before \label [1]. So the code you write becomes:
\begin{figure}[h]
\includegraphics[width=1\textwidth]{image1}
\caption{Απεικόνιση τρόπου κληρονομικότητας}
\label{fig:image1}
\end{figure}
Also, you were referring to the image incorrectly.
and you can refer it using \ref{fig:image1} to get the correct reference.
This will work well, as the key you use for \label is the key you use for \ref.
References
[1] https://tex.stackexchange.com/questions/32325/why-does-an-environments-label-have-to-appear-after-the-caption

Related

How do I use Option::unwrap_or_default when it contains a reference?

I have a candle_series of the type Vec<Candle> that gets the last element and I try to use unwrap_or_default:
self.candle_series.last().unwrap_or_default()
But then I get this error:
method not found in `std::option::Option<&market::Candle>
How can I get the behaviour of unwrap_or_default on the struct instead of the reference?
My current workaround is this but it seems incorrect. If it is correct, please let me know:
self.candle_series.last().unwrap_or(&Candle::default())
How can I get the behaviour of unwrap_or_default on the struct instead of the reference?
You'd need to either copy or move the reference (e.g. use Option::cloned, assuming your structure is Clone) so that your option is an Option<Candle>, and unwrap_or_default can do its job.
My current workaround is this but it seems incorrect.
Looks fine to me, though of course it might be shorter to use e.g. Candle::new() if you have such an initializer.

Matlab function defintion method that takes string as the definition (MFILE)

there is this method I used the other day and I have forgotten the details, which in we used a syntax like this:
f=//command//(x,'sin(x)');
something like this.
im not sure if the syntax is fully correct, or what the right command is. but after this we could simply ask for the f(x) value like this:
x= 0;
y= f(x);
and then the results were y=0;
What you are asking for is usually not recommendable. Please check if a simple anonymous function also fits your requirements:
f=#(x)(sin(x))
In case you really need to evaluate from a string:
f=str2func('#(x)sin(x)')
I would advice against the second option unless absolutely required, it can lead to hard to debug errors.
well I found the answer myself and it was "inline" command; :)
f=inline('sin(x+y+z)','x','y','z');
you can add as much variables as needed too.

Trying to write an IF ( Match ); possible syntax error?

Highly likely this is a syntax error, but it's not throwing any errors.
=IF(ISERROR(MATCH(MID(Z2,28,6),$AF$1:$AG1,0)),"Mismatch","Included")
I have Z2, Z2 contains the following text:
"Revenue account for invoice P13930."
Or something like that, so the Mid function is suppoused to match that code, P13930, and not if it is within the specified cells (Here, AF1 and AG1)
I tried copying the whole text, or even just the code to AF1 and AG1, but it never writes a match. What's wrong with it?
Based it on my prototype:
=IF(ISERROR(MATCH($AE1,$AF1:$AG$1,0)),"Mismatch","Included")
Which does happen to work.
EDIT: I forgot to mention, I was wondering how to include the following scenarios:
Sometimes the code would look like this: P13930. and other times like this: P13930A. I'm not sure how to consider these as my knowledge is limited to Mid , Left , and Right. And as Jordan Mentioned, MATCH would be out of the picture given these variations.
If AF1 and AG1 contain codes like P13930A, you can use a wild card to match them like this
=IF(ISERROR(MATCH(MID(Z2,29,6)&"*",$AF$1:$AG1,0)),"Mismatch","Included")
Could you please specify your question:
First which we can advice, is to correct mid function argument:
=IF(ISERROR(MATCH(MID(Z2,29,6),$AF$1:$AG1,0)),"Mismatch","Included")
MID(Z2,29,6) - will give you result P13930
and then you want to find this code in some area, don't you? for example in the area AF1:AG1.
Please specify the result which you want to see in the cell AF2:
(a) code P13930; (b) INCLUDED - if area AF1:AG1 includes code P13930; (c) MISMATCHED - if area AF1:AG1 does NOT include code P13930 and etc.

How to place latex-like mathematical formulas (e.g. via mathjax) in Haskell Diagrams?

I am attempting to place latex-style math formulas into a haskell diagram.
The documentation pages
http://projects.haskell.org/diagrams/doc/manual.html#essential-concepts
and
http://projects.haskell.org/diagrams/doc/tutorials.html
suggest that one can use something called 'mathjax' to achieve this.
Is there an explanation or example somewhere of how to actually code this?
Attempting to follow the documentation at those links, my best guess for how would be something like:
mathDiagram :: Diagram B
mathDiagram = stroke $ textSVG "`2 + \sqrt{\pi}`:math:" 1
But this of course gives an error:
induction.hs:13:35: error:
lexical error in string/character literal at character 's'
You can do this using the diagrams-pgf backend. Just use the text function and put dollar signs around your text. Also, see here for an explanation of how to include diagrams in a LaTeX document: http://projects.haskell.org/diagrams/doc/latex.html .

pgf/tikz: String Symbols as Input Coordinates

I'm new to pgf so i was trying out some examples from the pgfplot manual. One example is especially relevant for my current task but, alas, it would not compile.
Here is the code:
\documentclass[11pt]{article}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[symbolic x coords={a,b,c,d,e,f,g,h,i}]
\addplot+[smooth] coordinates {
(a,42)
(b,50)
(c,80)
(f,60)
(g,62)
(i,90)};
\end{axis}
\end{tikzpicture}
\end{document}
the compiler quits with the following error:
! Package PGF Math Error: Could not parse input 'a' as a floating point number,
sorry. The unreadable part was near 'a'..
I have no clue how to correct this behavior. Other plots (smooth, scatter, bar), which contain only numerical data compile fine.
Could anybody give me a hint?
Cheers
K.
You need to include this in the preamble:
\pgfplotsset{xticklabel={\tick},scaled x ticks=false}
\pgfplotsset{plot coordinates/math parser=false}
I had problems with this command when I tried to use it (specifically the "plot coordinates/math parser"), but then I updated the package pgfplots and it all worked.

Resources