Can't get alignment formatted in Latex - formatting

I have written this code:
\begin{align*}
T_n &=&\frac{1}{(n+2)n!}&=&\frac{n+1}{(n+2)(n+1)n!} \\
&=&\frac{(n+2)-1}{(n+2)(n+1)n!}&=&\frac{1}{(n+1)!}-\frac{1}{(n+2)!}
\end{align*}
I want to get something aligned to the left after each = sign
But what I am ending up getting is :

The second & with the first equation sign is too much, have a lok at this:
\begin{align*}
T_n &=\frac{1}{(n+2)n!}&=&\frac{n+1}{(n+2)(n+1)n!} \\
&=\frac{(n+2)-1}{(n+2)(n+1)n!}&=&\frac{1}{(n+1)!}-\frac{1}{(n+2)!}
\end{align*}

Related

Format percentage with or without decimal

I have a very simple issue in MS-Access and somehow the solution eludes me. I want to display a field that holds a percentage with or without decimals. So I want to display the decimal separator only when there is actually a decimal in the field. This illustrates the problem:
debug.? format(0.21, "0.#%"), format(0.215, "0.#%")
21,% 21,5%
How to get rid of the nasty comma in 21,%. I tired al sorts of format options. I either always get a decimal or I get the value rounded, which I do not want.
How can I display 0.21 as 21% and 0,215 as 21,5% ?
You can use IIf:
PercentValue = Format(Value, "0" & IIf(Value * 100 = Fix(Value * 100), "", ".##") & "%")
Value = 0.21 -> 21%
Value = 0.215 -> 21.5%

Dividing the input in python

I'm doing a project where I need to insert coordinates in the console to return a place in a grid. My grid is 10*10 and has numbers in the rows and Letters in the columns.
I want to be able to input something like A1 and for it to be interpreted as "column1, row1"
So far I have got:
def get_coor():
user_input = input("Please enter coordinates (row,col) ? ")
coor = user_input.split(" ")
return coor
But I'm only able to split if I have a space. Is there any other function to help me in this situation?
Strings are iterable in Python.
If you write:
user_input = input("Please enter coordinates (row,col)?")
<input A1>
Then user_input[0] will be A and user_input[1] will be 1.
Therefore, no need for the split :)
Split is used precisely for the use case when there is a space: it returns a list of all the strings between the occurrences of the character given as an argument (in your case a space).

How to remove zeroes after the decimal point as an expression in SSRS

I have the following expression in one of my textbox in my SSRS Report:
=IIF(IsNothing(Lookup(Trim(Fields!venta_Cod_vendedor.Value) & "-" & ReportItems!Textbox233.Value, Fields!AgregarVentas.Value, Fields!venta_prom_sem.Value, "EfectividadDeFrecuencias_Ventas")) = True
,"0"
,IIF(Lookup(Trim(Fields!venta_Cod_vendedor.Value) & "-" & ReportItems!Textbox233.Value, Fields!Agregar.Value, Fields!total_cant_pos.Value, "EfectividadDeFrecuencias_Total") <> "0"
,FormatNumber(Lookup(Trim(Fields!venta_Cod_vendedor.Value) & "-" & ReportItems!Textbox233.Value, Fields!AgregarVentas.Value, Fields!venta_frecuencia.Value, "EfectividadDeFrecuencias_Ventas")
/ Lookup(Trim(Fields!venta_Cod_vendedor.Value) & "-" & ReportItems!Textbox233.Value, Fields!Agregar.Value, Fields!total_cant_pos.Value, "EfectividadDeFrecuencias_Total"),2)
,"0"))
That division will give me an int64 number, 15 digits (If such math operation gives that amount of decimal digits).
So the results are:
Now here is the tricky part:
My code behind that grabs the Dataset does a round and converts to decimal and then shows to a Crystal Report.
dr.venta_prom_sem = (Convert.ToDouble(dr.total_cant_pos) != 0 ? (Math.Round((Convert.ToDouble(dr.venta_frecuencia) / Convert.ToDouble(dr.total_cant_pos)), 2)).ToString() : "0");
So this will give me:
as you can see if I use a format Number the 1.3 will convert to 1,30 and that will be wrong, same as 1 (1,00). Now 1,339...etc will give me 1,34 and that is fine.
But check the 1.065, with FormatNumber that will give me 1.07 instead of 1.06.
So the thing is, how can I format my numbers to be the last non zero digit after the decimal point AND select the lower value if the (in this case) 3rd value is 5, instead of 1.07 be 1.06. I think If I use Ceiling or Floor it gives me the integer part.
Try this:
=ROUND(1.339,2,MidpointRounding.ToEven)
This gives: 1.34
And
=ROUND(1.065,2,MidpointRounding.ToEven)
Gives: 1.06
Let me know if this was helpful.

Vi: how to automatically insert spaces

I'm trying to write a nice feature for crazy people like me who like there lines to be perfectly aligned.
I often write some file in which the format is "key = value".
Since the key may contain an indeterminate number of character, one have to manually align the "=" symbols which is not cool.
Is there a way to tell vi "when someone type the equal character, then insert as spaces as necessary to go to the column 25, then write an the equal symbol"?
The second step will be to define a shortcut to apply this format to an entire file.
Any help would be appreciated.
Ben.
Map the behavior of = in Insert Mode.
Next code will add spaces until column 24 from current cursor position and will add an equal sign after it. If there were characters after cursor position (suppose in a middle of a word), those characters will be moved after column 25. Add it to your vimrc file and try.
"" If length of the line is more or equal to 24, add an equal sign at the end.
"" Otherwise insert spaces from current position of cursor until column 24
"" and an equal sign, moving characters after it.
function My_align()
let line_len = strlen( getline('.') )
if line_len >= 24
s/$/=/
return
endif
let col_pos = col('.')
exe 's/\%#\(.\|$\)/\=submatch(1) . printf( "%' . (24 - col_pos) . 's%s", " ", "=" )/'
endfunction
inoremap = <Esc>:call My_align()<CR>A
For second step, use the multiple repeats command, check for an equal sign and insert spaces until column 25 just before it. Won't work if equal sign is after column 25 before executing it, but you get the idea.
:g/=/exe 's/=/\=printf( "%' . ( 24 - stridx( getline('.'), "=" ) ) . 's", " " ) . submatch(0)/'

insert a space after a specific character with awk?

How do I insert a space after a specific character with awk?
The test data
<>jhjashdhasdkh
I want to insert a space " " after > so the data string would become...
The modifyed test data now becomes...
<> jhjashdhasdkh
Does anyone know how to do that with awk. ? I've tried everything I can..
Thank you for helping,
You'll want to read about the sub and gsub functions in the gawk manual
In my case, I had to insert a decimal point after a number.
NewBid = substr(spotBidRate,1,1) "." substr(spotBidRate, 2)
The sample input: spotBidRate=367305000 The Sample output: NewBid=3.67305000
So in your case, it would be a space, NewBid = substr(spotBidRate,1,1) " " substr(spotBidRate, 2) Hope that helps!