I have a complicated longtable with several levels of nested tabular environments. To get text wrapping inside cells and have the contents aligned at the top I use \parbox[t][][t], however, the height of the parbox is computed without any margin such that the following \hline overlaps with the text.
A minimal example to reproduce this behavior is
\documentclass{article}
\begin{document}
\begin{tabular} {|p{0.2\textwidth}|}
\hline
This cell looks good. \\
\hline
\parbox[t][][t]{1.0\linewidth}{
Not so happy with this.
} \\
\hline
\end{tabular}
\end{document}
This produces the following output (sorry, can't post images yet):
image of generated output
Of course, there is no reason to use a parbox in example above, but I need them in the actual document.
I would like to avoid providing the height of the parbox (such as \parbox[t][5cm][t]). Is there a clean way to add a margin either to the bottom of a parbox or before an hline?
Sorry to answer my own question, but I have found a solution by adding vspace to each cell outside the parbox.
Here's the code:
\documentclass{article}
\begin{document}
\newcommand{\pb}[1]{\parbox[t][][t]{1.0\linewidth}{#1} \vspace{-2pt}}
\begin{tabular} {|p{0.2\textwidth}|}
\hline
This cell looks good. \\
\hline
\pb{
Now I'm happy with this.
} \\
\hline
\end{tabular}
\end{document}
The output: image of generated output
I missed that before because I didn't have a space between the closing brace of the parbox and the vspace. Turns out that space is crucial.
Related
I struggle to find a good regex match for that kind of sentence:
1) Remove the modern cement (20) render to the front of all three
properties 2) Inspect the sole plate and studs at front of all three
properties, repair where possible, and replace where rotten 3) Apply
sawn lath and lime render 4) Finish with limewash including pigment to
as closely match existing colour as possible (30)
The thing is to match 1), 2), 3), 4) but NOT (20) nor (30).
My try:
((?!\([0-9]+\))\s*\d+\s*\))
fails.
Any suggestions?
You may use
(?<![\d(])\d+\)
See the regex demo
Details
(?<![\d(]) - no digit or ( immediately to the left of the current location is allowed
\d+ - one or more digits
\) - a ) char.
Here is a Python code snippet that wraps the matches with {{ and }} (just for the demo purpose):
import re
text = "1) Remove the modern cement (20) render to the front of all three properties 2) Inspect the sole plate and studs at front of all three properties, repair where possible, and replace where rotten 3) Apply sawn lath and lime render 4) Finish with limewash including pigment to as closely match existing colour as possible (30)"
print( re.sub( r'(?<![\d(])\d+\)', r'{{\g<0>}}', text) )
Output:
{{1)}} Remove the modern cement (20) render to the front of all three properties {{2)}} Inspect the sole plate and studs at front of all three properties, repair where possible, and replace where rotten {{3)}} Apply sawn lath and lime render {{4)}} Finish with limewash including pigment to as closely match existing colour as possible (30)
Would like to use a VBA REGEX to extract from a given text the part number and manufacturer only:
BALL BEARING SKF 2209 ETN9/C3 | BALL BEARING SELF ALIGNING SKF 2209 ETN9/C3
SELF ALIGNING BALL BEARING 23222CCK/W33| TIMKEN BEARING;BALL 23222 CCK/W33
the output should be 2209 ETN9/C3 and TIMKEN 23222 CCK/W33
I tried ^(\bBEARING.+)BALL$ and ^(BEARING)|$, but it does not work.
Any help will be appreciated.
does the following do the job ?
\d+\s?[A-Z0-9]+\/[A-Z0-9]+
Selected matches:
Tested with www.regexr.com
[CDATA[The presence of proteins can be detected by the Biuret test.<br/>
(i) Crush the food sample and put some of it into a clean test tube. Add some
sodium hydroxide solution.<br/>
(ii) Cork the test tube and shake it to mix the food with the sodium hydroxide
solution. Then add a little copper sulphate solution. Cork and shake it
again.<br/>If the solution turns blue, there is no protein in the food. But it turns violet, there is protein in the food.]]
\[[^\[\]]*?\]
Try this.See demo.
http://regex101.com/r/sA8iT4/4
After a downloading process (thanks to jdownloader) I've thousands files like so:
Queen - Love of My Life (256kbit).m4a
Queen - Love of My Life (BQ).jpg
Queen - Bicycle (128kbit).m4a
Queen - Bicycle (HQ).jpg
Gary Jules - Mad World (256kbit).m4a
Gary Jules - Mad World (BQ).jpg
...
How can we embed the images to their audio files as album arts? Files are not exactly same but alike.
Using the Mp3tag application (http://www.mp3tag.de) you can apply the Mp3tag action ...
"Import cover from file".
This imports the cover art specified by the absolute or relative filename into the tag of the file.
You can use placeholders like %artist% or %album%.
You can use wildcards like ? or *.
So it should be feasable to do ... having ...
music file: Queen - Bicycle (128kbit).m4a
image file: Queen - Bicycle (HQ).jpg
... apply action ...
"Import cover from file".
Format string for image filename: $regexp(%_filename%,'\(.*$','*')
Import cover as: Front Cover
For image filename which is not exactly the same as the music filename, you may use a format string like ...
$regexp(%_filename%,'\W','?')'.jpg' ==> "Queen???Bicycle??128kbit?.jpg"
... this replaces all characters, which are not letters or numbers or underline character, with the ? wildcard.
$regexp(%_filename%,'\W+','*')'.jpg' ==> "Queen*Bicycle*128kbit*.jpg"
... this replaces all sequences of characters, which are not letters or numbers or underline character, with the * wildcard.
$regexp($regexp(%_filename%,'\(.*\)$','*'),'\W+','*')'.jpg' ==> "Queen*Bicycle*.jpg"
... this replaces all sequences of characters, which are not letters or numbers or underline character, with the * wildcard, and removes the trailing parenthetical expression.
DD.20140503.1620.CEST
My text example:
this is my text,this is,this is my text
this, this is my,this is my,this is text
I use Tabular plug-in to align text.
When I want to align at the 1st and 2nd occurrence of a single space '\s' I use these lines:
Tabularize /^\(.\{-}\zs\s\)\{1}/l0
Tabularize /^\(.\{-}\zs\s\)\{2}/l0
But I noted that the 1st alignment add spaces in order to align,
but the 2nd alignment is influenced by these extra spaces added and does not the right job.
How can I avoid this?
(I hope I made myself clear)
Edit:
This is what I expected:
this is my text,this is,this is my aatext
this, this is my,this is my,this is rtext
This is the outcome:
this is my text,this is,this is my aatext
this, this is my,this is my,this is rtext
Edit2:
This is my example with >= 2 spaces:
this is my text, this is,this is my aatext
this, this is my, this is my, this is rtext
Adapting the code proposed by Nikita Kouevda in his answer below:
Tabularize /\(^\(\(\S*\s\{2,}\)\{0}\|\(\S*\s\{2,}\)\{2}\)\)\#<=\S*\zs\s/l0
I expected:
this is my text, this is,this is my aatext
this, this is my, this is my, this is rtext
Outcome:
this is my text, this is,this is my aatext
this, this is my, this is my, this is rtext
I'm not familiar with Tabular and there might be an option to do this, but I would simply change the second \s to \s\+ in order to match any amount of whitespace:
Tabularize /^\(.\{-}\zs\s\+\)\{2}/l0
Edit: Here's a more proper solution, combining the steps into one:
Tabularize /\(^\(\S*\s\)\{,1}\)\#<=\S*\zs\s/l0
The first part is a lookbehind that matches up to the 0th or 1st space, any non-whitespace characters are then skipped, and the next space is matched (the 1st and 2nd, respectively). This can be generalized to any range; e.g. to align by the 2nd through 5th spaces, use \{1,4}.
Edit: If you need to align by a set of spaces that do not constitute a range in that sense, I would utilize logical ORs in the lookbehind. Unfortunately, this becomes much more clumsy and repetitive. For example, to align by the 1st and 3rd spaces:
Tabularize /\(^\(\(\S*\s\)\{0}\|\(\S*\s\)\{2}\)\)\#<=\S*\zs\s/l0
In order to align each column differently, specify multiple [lcr]# formats. Note that every separating and separated column is counted; e.g. an alignment by 2 spaces results in 5 columns that will be formatted. In order to align by the 1st and 3rd spaces, and to right justify the middle column of text:
Tabularize /\(^\(\(\S*\s\)\{0}\|\(\S*\s\)\{2}\)\)\#<=\S*\zs\s/l0l0r0l0l0
Since the formats cycle if you specify fewer than the number of columns, l0l0r0 would also suffice here, but it's probably a good idea to be explicit.