How can I get a cedilla within an equation block? [closed] - latex

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
I'm writing a document in latex and I can't get the cedilla character working within an equation block. My current charset is utf8, \c{c} don't work as stated in many LaTeX documents.
I'm trying the following:
\begin{equation}
\label{eq:accuracy}
confiança = \frac{tp + tn}{tp + fp + fn + tn}
\end{equation}
The workaround given here don't work.

There are two issues here. First, \c{c} does not work in math mode. You need to switch back to text mode (\textit preserves the italics and does not require amsmath):
\begin{equation}
\label{eq:accuracy}
confian\textit{\c{c}}a = \frac{tp + tn}{tp + fp + fn + tn}
\end{equation}
The second is that writing a full word in math mode will give you terrible kerning. Compare with this:
\begin{equation}
\label{eq:accuracy}
\textit{confian\c{c}a} = \frac{tp + tn}{tp + fp + fn + tn}
\end{equation}

Related

List of listing style in Latex [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
I try to create a list of listing my code snippets in my latex document
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{minted}
\usepackage{listings}
\renewcommand\lstlistingname{Code}
\renewcommand\lstlistlistingname{List of code snippets}
\title{Code Listing}
\begin{document}
\maketitle
\section{Code examples}
\begin{listing}
\begin{minted}
[
frame=lines,
framesep=2mm,
baselinestretch=1.2,
fontsize=\footnotesize,
linenos
]
{python}
import numpy as np
def incmatrix(genl1,genl2):
m = len(genl1)
n = len(genl2)
M = None #to become the incidence matrix
VT = np.zeros((n*m,1), int) #dummy variable
#compute the bitwise xor matrix
M1 = bitxormatrix(genl1)
M2 = np.triu(bitxormatrix(genl2),1)
for i in range(m-1):
for j in range(i+1, m):
[r,c] = np.where(M2 == M1[i,j])
for k in range(len(r)):
VT[(i)*n + r[k]] = 1;
VT[(i)*n + c[k]] = 1;
VT[(j)*n + r[k]] = 1;
VT[(j)*n + c[k]] = 1;
if M is None:
M = np.copy(VT)
else:
M = np.concatenate((M, VT), 1)
VT = np.zeros((n*m,1), int)
return M
\end{minted}
\caption{Example of code}
\label{lst:code1}
\end{listing}
\clearpage
\lstlistoflistings
\end{document}
I don't know why my list look like this:
My caption under minted should change to Code 1: Example of code
Caption Solution
replace:
\renewcommand\lstlistingname{Code}
to:
\renewcommand{\listingscaption}{Code}
I read a lot of post but still not found the solution.. :(
I will be grateful for any help
First of all, questions like this should be asked on tex.stackexchange.
As for the question itself, you're mixing two packages here. minted is separate from listings, so the commands from the latter work weirdly on the environments from the former (technically, they shouldn't work at all, but it's TeX we're talking about). According to minted's docs, that's what you should do:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{minted} % don't need to import `listing` or `listings`
% custom labels, according to the docs
\renewcommand\listingscaption{Code}
\renewcommand\listoflistingscaption{List of code snippets}
\title{Code Listing}
\begin{document}
\maketitle
\section{Code examples}
\begin{listing}[H] % creates a float
\begin{minted} % does the syntax highlighting
[
frame=lines,
framesep=2mm,
baselinestretch=1.2,
fontsize=\footnotesize,
linenos
]
{python}
your_code(...)
\end{minted}
\caption{Example of code}
\label{lst:code1}
\end{listing}
This is a reference to Code~\ref{lst:code1} to make it appear in the list of listings.
\clearpage
\listoflistings % NOT `lstlistoflistings`
\end{document}
Result:

Can we override operators in Ruby? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
in a case...such as
(10 + 20) * 10
=> 300
the expression fragment enclosed in parentheses is evaluated before the higher precedence multiplication.So does it applies to other operators as well.Can i override other operators such as << !...etc
When humans evaluate expressions, they usually do so starting at the left of the expression and working towards the right. For example, working from left to right we get a result of 300 from the following expression:
10 + 20 * 10 = 300
This is because we, as humans, add 10 to 20, resulting in 30 and then multiply that by 10 to arrive at 300. Ask Ruby to perform the same calculation and you get a very different answer:
> 10 + 20 * 10
=> 210
This is a direct result of operator precedence. Ruby has a set of rules that tell it in which order operators should be evaluated in an expression. Clearly, Ruby considers the multiplication operator (*) to be of a higher precedence than the addition (+) operator.
Overriding Operator Precedence
The precedence built into Ruby can be overridden by surrounding the lower priority section of an expression with parentheses. For example:
> (10 + 20) * 10
=> 300
In the above example, the expression fragment enclosed in parentheses is evaluated before the higher precedence multiplication.
for more info refer this :
http://rubysnippets.com/2013/01/25/operator-overloading-in-ruby/
Override == operator in Ruby
I hope this makes you clear to understand :)
yes you can,you can do it like this
class String
def << str
self + "*" + str
end
end
puts "str" << "sss"

Latex quetion "Missing $ inserted" [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
I want to write this simple equation in latex
2/|w|
In which |w| is the norm of w,,
I tried with
\frac{2}{\|w\|}
And get error "Missing $ inserted"
then I use this
\frac{2}{$\|w\|$}
And still get same error..
Does someone know how to solve this problem??
You are getting that error because LaTeX recognized this as being part of an equation and tried to correct it automagically. Unfortunately that rarely works well. You need to tell LaTeX that this is an equation.
To round out #nicoguaro's answer, use this form for equations that will be numbered and stand alone in the text:
\begin{equation}
\frac{2}{\left| w \right|}
\end{equation}
Or, use this form for equations that form part of a sentence:
blah blah $\frac{2}{\left| w \right|}$ blah blah.
Are this expression inside a mathematical environment like
\begin{equation}
...
\end{equation}
or $ $, \( \), \[ \] ?
The expression can be written as (using \[ \])
\[\frac{2}{\vert w \vert}\]
or just
\[\frac{2}{| w |}\]
You can see this book in Wikibooks. You need to specify that the whole expression is a mathematical expression enclosing it in its delimiters.

Implicit linebreaks in LaTeX equations

I wonder if there is any way to invert the way the LaTeX interprets linebreaks in equations? E.g., I dont want to insert them explicitly like,
\begin{gather}
x = y \\
a = c
\end{gather}
, but implicitly like,
\begin{gather}
x = y
a = c
\end{gather}
Thanks.
This is against the intention of TeX’s author, who believed that math must be typeset by hand. I tried obeylines, but to no avail. I guess it’s possible by making new line active, but you should ask the cracks over at Stack Exchange, a branch of Stack Overflow for TeX and LaTeX.
The breqn package will automatically insert linebreaks in equations when the line is full. I don't know of anything that will do break as you ask. If it is a big deal you could use perltex to define a macro that would do it for you. I will try to mock one up as an example.

How to strike out inside LaTeX equations? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Please see the snippet below and tell me how can I achieve the same strike-out effect as in the main text. I am using the version of LaTeX from the latest Ubuntu repositories.
\documentclass{article}
\usepackage{ulem}
\begin{document}
The sout tag works perfect in the \sout{main text area} but not inside the equations.
$$
list = [1, \sout{2}, 3, \sout{4}, 5, \sout{6}, 7, \sout{8}, 9, \sout{10}]
$$
Any clue?
\end{document}
Here is LaTeX output
It looks like the \sout doesn't work inside a math env.
You can try doing something like this, which works:
\documentclass{article}
\usepackage{ulem}
\begin{document}
The sout tag works perfect in the \sout{main text area} but not inside the equations.
$list = $[1, \sout{2}, 3, \sout{4}, 5, \sout{6}, 7, \sout{8}, 9, \sout{10}$]$
Any clue?
\end{document}
If anyone's still interested, I just found out about the cancel package, which allows you to strike your text in math mode in a few different ways. It's not horizontal, though -- only diagonal, which in my case is much better.
If you need to keep the strikeout in Math mode (e.g., to keep Math fonts) try:
\newcommand{\msout}[1]{\text{\sout{\ensuremath{#1}}}}
then
$\msout{\mathsf{stuckout}}$
you need amsmath and ulem.
(Solution from here.)
Pretty much any non-math-mode command can be used inside mathmode by putting it within a \text{} environment, e.g.:
\documentclass{article}
\usepackage{ulem}
\begin{document}
The sout tag works perfect in the \sout{main text area} but not inside the equations.
\[ list = [1, \text{\sout{2}}, 3, \text{\sout{4}}, 5, \text{\sout{6}}, 7, \text{\sout{8}}, 9, \text{\sout{10}}] \]
Any clue?
\end{document}
And if you'd like to be able to use strike-out without having ulem redefine how \emph{} works, use \usepackage[normalem]{ulem}.

Resources