Inkscape: how to attach superscript and subscript to the same character - inkscape

I want to add both superscript and subscript to the same character in the Inkscape text object. Currently, I have this:
but I want apostrophe (') and 0 to be aligned vertically so that x has (') as superscript and 0 as subscript.

You can use negative horizontal kerning on your zero indices. Look at the red framed field in the upper right.
The SVG for the text element will look like this:
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.584px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.2646"
x="29.4"
y="29.48"
id="text3715"><tspan
sodipodi:role="line"
id="tspan3713"
x="29.4"
y="29.48"
style="stroke-width:0.2646"
dx="0 0 0 0 5 0 0 0 3.5">(x'<tspan
style="font-size:65%;baseline-shift:sub"
id="tspan3717"
dx="-3.5">0</tspan>,y'<tspan
style="font-size:65%;baseline-shift:sub"
id="tspan3719"
dx="-3.5">0</tspan>)</tspan></text>
Note the dx="-3.5" attributes.

Related

formatting setw() function equivalent to 1 \t tab [duplicate]

I want to implement a text drawing function. But I am not sure how \t works, which means I don't know how many spaces I should print for \t.
I have come up with the following algorithm:
a) Each \t represents at most NUMBER_OF_SPACES_FOR_TAB spaces.
b) If \t appears in the last line at a corresponding position, \t for this line should be aligned to the \t of last line.
Example:
printf("a\t\tb\n");
printf("\t\tc\n");
Should print:
a11112222b
34444c
Where:
1.Number i represents the spaces of \t at position i
2.NUMBER_OF_SPACES_FOR_TAB == 4
Does anyone know the standard algorithm? Thanks in advance.
A tab character should advance to the next tab stop. Historically tab stops were every 8th character, although smaller values are in common use today and most editors can be configured.
I would expect your output to look like the following:
123456789
a b
c
The algorithm is to start a column count at zero, then increment it for each character output. When you get to a tab, output n-(c%n) spaces where c is the column number (zero based) and n is the tab spacing.
Imagine a ruler with tab stops every 8 spaces. A tab character will align text to the next tab stop.
0 8 16 24 32 40
|.......|.......|.......|.......|.......|
printf("\tbar\n"); \t bar
printf("foo\tbar\n"); foo\t bar
printf("longerfoo\tbar"); longerfoo\t bar
To calculate where the next tab stop is, take the current column.
nextTabStop = (column + 8) / 8 * 8
The / 8 * 8 part effectively truncates the result to the nearest multiple of 8. For example, if you're at column 11, then (11 + 8) is 19 and 19 / 8 is 2, and 2 * 8 is 16. So the next tab stop from column 11 is at column 16.
In a text editor you may configure tab stops to smaller intervals, like every 4 spaces. If you're simulating what tabs look like at a terminal you should stick with 8 spaces per tab.
A Tab character shifts over to the next tab stop. By default, there is one every 8 spaces. But in most shells you can easily edit it to be whatever number of spaces you want (profile preferences in linux, set tabstop in vim).

Regex to match position from right to left

I hope you can help me, I'm studying how to make a regex and now I have this problem:
Write a regex that accepts strings with 0 and 1 and that has a 1 on position 5 from right to left.
e.g. 10000 is accepted because it has an 1 on the position 5 from right to left or 010000, 0010000 or 1110000 are accepted.
I was thinking with something like: (0+1)*+1(0+1)(0+1)(0+1)(0+1)(0+1)
You can use this regex:
1[01]{4}$
If you want to match full input then use:
^[01]*1[01]{4}$
Here 1[01]{4}$ ensures that we have 4 digits of 0 and 1 after we match 1 thus making 1 at 5th position from right to left.
RegEx Demo
Well - think of it this way. It needs to be as many 1s and 0s as you please, followed by a 1, followed by 4 more ones or zeroes.
So:
my_regex =
"^[01]*" + // Starts with One or zero, zero or more times
"1" + // Followed by a one
"[01]{4}$" // Followed by four things, which could be either zero or one, before ending.
Your (0 + 1) syntax looks foreign to me. I'm using character classes to specify the [01] things but you could use (0|1) in their place, which is what your attempt looks more like.
The full thing, together, is ^[01]*1[01]{4}$

Notepad++ - Searching for elevated lines that don't end with "\r

I am working in Notepad++ and I'm looking for a solution to an issue I'm having.
I have a few hundred thousand lines of code that I need to check with regex.
Basically, I need to check for any elevated lines (3-tabbed) that don't end with a parentheses and newline. ("\r)
Here's an example of the code:
side
{
"id" "13"
"plane" "(-1152 256 1) (-1152 256 -0) (2048 256 -0)"
"material" "CONCRETE/CONCRETEFLOOR001A
"uaxis" "[1 0 0 0] 0.25"
"vaxis" "[0 0 -1 0] 0.25"
"rotation" "0"
"lightmapscale" "16"
"smoothing_groups" "0"
}
You can see that the Material line is missing a parentheses. I need a way to find these lines that are missing them.
Thank you for your help!
^\s+".*(?<!")$\r\n
This expression finds lines which:
Starts with white spaces, following with a "
Ends with " and new line character (\r\n)

Return some middle portion if length is over x?

I'm currently using a RegEx like so (.{12}$)|(^.{1,12}$) - something like "if the value is 1 to 12 long, return them, else return the last 12."
I'm looking to add another clause, where if the length is greater than 16, I need to return a subset of it (specifically, starting at the 5th character, return 12).
How can I do this within the same RegEx?
It seems to work with
(?<=^.{4}).{12}|^.{1,12}$
This contains two parts. The first one handles strings at least 16 characters in length. For that it starts matching at the fifth character (that's what the (?<=^.{4}) is for – ensuring that there are exactly four characters preceding). After that there have to be at least 12 characters which are matched.
The second part is just for strings with 1–12 characters, matching the complete string.
Quick PowerShell test:
PS> '12345','1234567890','abcdefghijklmnopqrst'|%{if($_-match'(?<=^.{4}).{12}|^.{1,12}$'){$Matches}}
Name Value
---- -----
0 12345
0 1234567890
0 efghijklmnop

I'm trying to do a search/replace using regex for mass replacing on Notepad++

I need to add a parameter for each code and name, i tried using (.+) or (.*) for each number, but it didnt work. Each space means that is a different number and not every space has the same width. Example from this:
Abanda CDP 192 129 58 0 0 0 2 3 3
2.998 0.013 33.091627 -85.527029 2582661
To this:
Abanda CDP |code1=192 |code2=129 |code3=58 |code4=0 |code5=0 |code6=0 |code7=2 |code8=3 |code9=3
|code9=2.998 |code10=0.013 |code11=33.091627 |code12=-85.527029 |code13=2582661
Try ([0-9.-]+). The reason .+ doesn't work is because . matches whitespace as well. The reason you can't just use \S+ (non-spaces) is because you only want to match the numbers.