I'm trying to get an enumeration with my own specific formatting in two different ways (homework assignment to copy something someone else made):
-the numbers look like (1), (2), (3), etc.
-there is no spacing before or after the enumeration or between its items
I can get each of those two things at a time after loading the enumitem package with shortlabels with the following different snippets of code, respectively:
\begin{enumerate}[(1)]
\item item 1
\item item 2
\end{enumerate}
\begin{enumerate}[nolistsep]
\item item 1
\item item 2
\end{enumerate}
The former makes the numbers be (1), (2), etc. and the latter removes spacing. However, I can't do both at once without LaTeX refusing to compile it because it can't see the items afterwards:
\begin{enumerate}[(1)][nolistsep]
\item item 1
\item item 2
\end{enumerate}
I'm sure there's a proper syntax to use 2 different square-bracket arguments at once, but I can't find it, because Googling this issue only finds people trying to create commands with more than one argument.
EDIT: Nevermind. I immediately figured it out. I just needed a comma:
\begin{enumerate}[(1), nolistsep]
\item item 1
\item item 2
\end{enumerate}
I'm gonna leave this here for Google to find, because it's dumb how much of a sweet spot this issue is in, between being hard to find in a manual or examples and hard to find from Googling.
Nevermind. I immediately figured it out. I just needed a comma:
\begin{enumerate}[(1), nolistsep]
\item item 1
\item item 2
\end{enumerate}
I'm gonna leave this here for Google to find, because it's dumb how much of a sweet spot this issue is in, between being hard to find in a manual or examples and hard to find from Googling.
Related
I have a question about Tableau and I was hopping to get some help here.
Goal:
Visualize 3 different paths(bars, line and dotted line) in one visual.
What I have done:
To visualize two paths(bars and line) in one visual I have used Dual Axis which works well. Problem is that now, one if the lines we have I would like to show it as a dotted line, but if I change one, it seems that all the other lines are changed to the same path. Would you know how to tackle this this challenge?
Adding screenshot for more clarification.
Thanks in advance!
I know there are a lot of resources with regex for it. But I could not find the one I want.
My problem is:
I want to remove one line comments (//) from obj-c sources, but I don't want to break the code in it. For instance, with this regex: #"//.*" I can remove all comments, but it also corrupts string literal:
#"bsdv//sdfsdf"
I played with non-capturing parentheses (?:(\"*\")*+), but without success.
Also I found this expression for Python:
r'(\".*?\"|\'.*?\')|(/\*.*?\*/|//[^\r\n]*$)'
It should cover my case, but I've not figure out how to make it work with obj-c.
Please, help me to build proper regex.
UPDATE: Yeah, that's a tough one, I know there're a lot of caveats, other than the one I described. I would appreciate if someone post regex that only fix my issue. Anyway, I gonna post my solution, without regex soon, I hope it will be helpful for anyone who struggling with such problem too.
Try this regex:
(?:^|.*;(?!.*")|#(?:define|endif|ifn?def|import|undef|...).*)\s*(//[^\r\n]+$)
Demo
http://regex101.com/r/jT4xC8
Description
Discussion
Besides all the warnings expressed in the comments, I assume that a single line can appear in two distinct cases:
Case 1: Alone on its line preceded or not by blank chars
Case 2: Not Alone on its line preceded or not by blank chars, and other chars.
In the first case, we match the beginning of the line (^ with /m flag). Then we search zero or more blank chars (\s*) and finally the single line comment: //[$\r\n]+$.
In the second case, if there are other chars on the line, they form statements. Any statement is ended by a semicolon ;. So we search the last statement and its corresponding semicolon .*;(?!.*"). Then we search the single line comment. Those other chars can be also preprocessor statements. In this case, they are introduced by a sharp #.
One important keypoint is that I assume the code passed to the regex is a code that compiles.
There is more
Don't forget also to add some other pre-processor directives that may apply in your case. Check this SO answer: https://stackoverflow.com/a/18014883/363573
I want to make a search/replace macro in word which is on 2 or 3 rows, like this
"art. 2
2
pct. 22 din"
and convert it to this
"art. 2<sup>2</sup>
pct. 22 din"
instead of art. i can have other words too like lit., pct., alin. and the numbers are always different
i tried to use the next wildcard replace but it doesn't work:
search: "(art. )([0-9]{1;})(^13)([0-9]{1;})(^13)"
replace: "\1\2<sup>\3</sup>^p"
if i type only (art. )([0-9]{1;})(^13) at the search field it works, but if i type the rest it doesn't find anything
Probably a bit late to be helpful, but I think this will do the trick, if I odd the horrible Word syntax correctly (I used this guide to check).
Search: ([a-z]#. )([0-9]#)^13([0-9]#)^13
With your replace as before.
First line match:
([a-z]#. ) - Any lower case letter occurring 1 or more times, followed by a dot.
([0-9]#) - Any digit occurring one or more times.
^13 - Paragraph mark.
Second line match:
([0-9]#) - Any digit occurring one or more times.
^13 - Paragraph mark.
If you find yourself doing stuff like this a lot, it might be worth using something that supports more common regular expressions (e.g. Notepad++ or similar). You might find the syntax a little bit more readable, and it would have the added bonus of teaching you something you can apply across many other environments.
I am essentially attempting to replace all of the footnotes in a large text. There are various reasons I am doing this in Objective-C, so please assume that constraint.
Every footnote beings with this: [Footnote
Every footnote ends with this: ]
There can be absolutely anything between those two markers, including line breaks. However, there will never be ] between them.
So, essentially I want to match [Footnote, then match anything except ], until ] is matched.
This is the closest I have been able to get to identifying all of the footnotes:
NSString *regexString = #"[\\[][F][o][o][t][n][o][t][e][^\\]\n]*[\\]]";
Using this regular expression manages to identify 780/889 footnotes. It also appears that none of those 780 are false alarms. The only ones it appears to miss are those footnotes that have line breaks in them.
I have spent a lengthly amount of time on www.regular-expressions.info, specifically on the page about dots (http://www.regular-expressions.info/dot.html). This has helped me to create the above regular expressions, but I have not truly figured out how to include any character or line break, except right bracket.
Using the following regular expression instead manages to capture all of the footnotes, but it captures way too much text, because * is greedy: (?s)[\\[][F][o][o][t][n][o][t][e].*[\\]]
Here is some sample text that the regular expression is run on:
<p id="id00082">[Footnote 1: In the history of Florence in the early part of the XVIth century <i>Piero di Braccio Martelli</i> is frequently mentioned as <i>Commissario della Signoria</i>. He was famous for his learning and at his death left four books on Mathematics ready for the press; comp. LITTA, <i>Famiglie celebri Italiane</i>, <i>Famiglia Martelli di Firenze</i>.—In the Official Catalogue of MSS. in the Brit. Mus., New Series Vol. I., where this passage is printed, <i>Barto</i> has been wrongly given for Braccio.</p>
<p id="id00083">2. <i>addi 22 di marzo 1508</i>. The Christian era was computed in Florence at that time from the Incarnation (Lady day, March 25th). Hence this should be 1509 by our reckoning.</p>
<p id="id00084">3. <i>racolto tratto di molte carte le quali io ho qui copiate</i>. We must suppose that Leonardo means that he has copied out his own MSS. and not those of others. The first thirteen leaves of the MS. in the Brit. Mus. are a fair copy of some notes on physics.]</p>
<p id="id00085">Suggestions for the arrangement of MSS treating of particular subjects.(5-8).</p>
When you put together the science of the motions of water, remember to include under each proposition its application and use, in order that this science may not be useless.--
[Footnote 2: A comparatively small portion of Leonardo's notes on water-power was published at Bologna in 1828, under the title: "_Del moto e misura dell'Acqua, di L. da Vinci_".]
In this example there are two footnotes and some non-footnote text. The first footnote, as you can see, contains two line breaks inside it. The second one contains no line breaks.
The first regular expression I mentioned above will manage to capture Footnote 2 in this example text, but it will not capture Footnote 1 because it contains line breaks.
Any improvements on my regular expression would be most appreciated.
Try
#"\\[Footnote[^\\]]*\\]";
This should match across newlines. No need to put a single character into a character class, either.
As a commented, multiline regex (without string escapes):
\[ # match a literal [
Footnote # match literal "Footnote"
[^\]]* # match zero or more characters except ]
\] # match ]
Inside a character class ([...]), the caret ^ takes on a different meaning; it negates the contents of the class. So [ab] matches a or b, whereas [^ab] matches any character except a or b.
Of course, if you have nested footnotes, this will malfunction. A text like [Footnote foo [footnote bar] foo] will match from the beginning until bar]. To avoid this, change the regex to
#"\\[Footnote[^\\]\\[]*\\]";
so neither opening nor closing brackets are allowed. Then of course, you only match the innermost Footnotes and will have to apply the same regex twice (or more, depending on the maximum level of nesting) to the entire text, "peeling back" layer by layer.
What is the easiest/simplest way of finding out the number of lines in your VB project?
You might be interested to know how this can be a relevant metric: Wikipedia SLOC
On a linux/mac, to count lines in files matching a certain extension ('vbs'):
find . -regex '.*.(vbs)' -print0 | xargs -0 cat | wc -l
Third party software, like VB Pure Lines of Code
if you're in Visual Studio, look at the line number on the left. If you want the total for all your pages, open them up, look at all your numbers, add them.
There a ton of utilities out there that will count lines for you. They typically count total lines, comment lines, white space lines, and code lines. Just Google your particular language and you'll find plenty.
What would you wanna see? Logical lines of code, or number of physical lines? Strictly, lines of code does not count empty lines, comments, and generated code lines. There is no easy way to find out lines of code in VB. Maybe you find something here.