I need to write articles and switch from latex to pandoc (better: I intend to do so). My markdown file looks like this:
....
bla bla
\noindent
\setlength{\parindent}{-0.2in}
\setlength{\leftskip}{0.2in}
\setlength{\parskip}{8pt}
# References
Mind, References really is the last line of the file.
I compile like this:
pandoc ../../bibliography/default.yaml -f markdown-tex_math_dollars -s --bibliography ../../bibliography/bibliography.bib --csl ../../bibliography/harvard-cite-them-right.csl -F pandoc-crossref $f -o $f.pdf
My default yaml file:
---
geometry: a4paper,verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=1.5cm,rmargin=1.5cm
inputenc: latin9
indent: true
sectionsDepth: 3
link-citations: true
numberSections: true
linestretch: 1.5
header-includes:
- \renewcommand{\familydefault}{\rmdefault}
- \usepackage{lineno}
- \linenumbers
---
And what I get in PDF is this:
As you can see, there's an empty line after References.
Q:
How can I get rid of this empty line?
How can I remove the numbering from section title References only, leaving the remaining section titles numbered?
Thanks
Related
The problem is:
A software called "RGI" will automatically append .txt as suffix to the output file. So if my sampleID is 7. Then the actual RGI output file will be 7.txt, which is different from the output file (7) defind in the snakefile rule. And snakemake will report errors like Job Missing files after 20 seconds. However, RGI still appends .txt as suffix even if you have preset a suffix (and the actual output file will look like 7.txt.txt).
How can I solve the problem?
The following is a part of my code:
rule rgi:
output:
cardTxt = "{sampleId}/annotation/rgi/{sampleId}"
input:
faa = rules.prokka.output.faa,
cardDb = config['rgi']['cardDb']
shell:
"""
rgi load -i {input.cardDb}
rgi main -i {input.faa} -t protein -o {output.cardTxt} --include_loose --clean
"""
Strip the .txt prefix from the output filename before passing it to rgi. I do this here using bash string manipulation but you can do it in other ways:
rule rgi:
input:
faa = rules.prokka.output.faa,
cardDb = config['rgi']['cardDb'],
output:
cardTxt = "{sampleID}/annotation/rgi/{sampleID}.txt",
shell:
"""
card=${{{output.cardTxt}%.txt}}
rgi load -i {input.cardDb}
rgi main -i {input.faa} -t protein -o $card --include_loose --clean
"""
(I assume you want .txt to be part of the output filename. I.e. you are ok with 7.txt)
I have a makefile where I want to read file name from input and then make other names based on it`s name. I have tried the following code
mlext = .ml
testext = test.ml
nativeext = test.native
test:
#read -p "Enter file name: " file; \
echo $$file$(mlext); \
echo $$file$(testext); \
echo $$file$(nativeext)
for example:
If i type: foo
then I want to get foo.ml, footest.ml, footest.native
however, I can only get foo.ml. For the rest two i only get .ml and .native
How can i fix this?
First, let us see what is the exact recipe given to the shell by removing the # in your Makefile:
read -p "Enter file name: " file; \
echo $file.ml; \
echo $filetest.ml; \
echo $filetest.native;
The issue is thus that the content of $(testext) gets appended to $$file, creating the shell variable $filetest, which (very probably) does not exist, resulting in an empty string in the end. This does not occur with $(mlext), as the initial dot cannot be part of a variable name.
To overcome this, use $${file} instead of $$file in your Makefile rule.
My makefile has:
debug:
W1 := foo bar cat
I want to extract each word foo, bar and cat and get the output as below:
v1=foo
v2=bar
v3=cat
I tried:
W1 :=foo bar cat
v1 :=$(word 1, $$(W1))
v2 :=$(word 2, $$(W1))
v3 :=$(word 3, $$(W1))
debug:
#echo "${v1}"
#echo "${v2}"
#echo "${v3}"
Does not work the way I wanted. Please help
(Answered in a comment. See Empty InfoWindow when Marker is clicked )
#MadScientist wrote:
Why are you using double-dollar signs? That simply tells make to not expand the value, so you definitely won't get what you want. Use $(word 2,$(W1)) etc.
#Etan Reisner wrote:
Also since the variables are make (and not shell) variables you can use echo '${v1}' (or echo '$(v1)' which would be my preference) in the rule body instead of using double quotes.
In puppet, if define command is > 80 characters, how can I wrap into two line to do it?
exec { 'create_domain':
command => "some command exceed 80 character...........................................................how to do how to do?.......",
}
It's sort of ugly, but if the last character in a string is a \ followed by a newline, then the string is continued on the next line. My sample.pp manifest is below:
exec { 'wrapped_string_example':
command => "/bin/echo 12345678901234567890123456789012345678901234567890\
wrapped > /var/tmp/test.txt";
}
Running this with puppet apply sample.pp gives the following output
$ puppet apply sample.pp
notice: /Stage[main]/Exec[wrapped_string_example]/returns: executed successfully
notice: Finished catalog run in 0.10 seconds
And catting the created file shows the lines have wrapped:
$ cat /var/tmp/test.txt
12345678901234567890123456789012345678901234567890wrapped
See https://github.com/puppetlabs/puppet/blob/9fbb36de/lib/puppet/parser/lexer.rb#L537 (as of Puppet v2.7.0)
Also this is sort of a known issue: http://projects.puppetlabs.com/issues/5022
For big chunks of data, heredocs are the best way of dealing with long lines in Puppet manifests. The /L interpolation option is particularly useful. /L causes \ at the end of a line to remove newlines. For example, the following does what you'd expect, stripping indentation and newlines, including the trailing newline.
sshkey { 'example.com':
ensure => present,
type => 'ssh-rsa',
key => #(KEY/L),
RfrXBrU1T6qMNllnhXsJdaud9yBgWWm6OprdEQ3rpkTvCc9kJKH0k8MNfKxeBiGZVsUn435q\
e83opnamtGBz17gUOrzjfmpRuBaDDGmGGTPcO8Dohwz1zYuir93bJmxkNldjogbjAWPfrX10\
8aoDw26K12sK61lOt6GTdR9yjDPdG4zL5G3ZjXCuDyQ6mzcNHdAPPFRQdlRRyCtG2sQWpWan\
3AlYe6h6bG48thlo6vyNvOD8s9K0YBnwl596DJiNCY6EsxnSAhA3Uf9jeKqlVqqrxhEzHufx\
07iP1nXIXCMUV
|-KEY
target => '/home/user/.ssh/authorized_keys',
}
Or to keep the final newline, leave out the - before the end text:
exec { 'create_domain':
command => #(CMD/L),
/bin/echo 123456789012345678901234567890123456789012345678901234567890123456\
wrapped > /var/tmp/test.txt
| CMD
}
As of Puppet 3.5 you have a couple of options that i have used. Ruby allows you to concat strings over a couple of lines.
string = "line #1"\
"line #2"\
"line #3"
p string # => "line #1line #2line #3"
Another option, as of Puppet 3.5 they have added HereDoc functionality. This will allow you to put the string in a section of a source code file that is treated as if it were a separate file.
$mytext = #(EOT)
This block of text is
visibly separated from
everything around it.
| EOT
The puppet documentation is here: https://docs.puppet.com/puppet/4.9/lang_data_string.html#heredocs
If you really care about the 80cols limit you can always abuse a template to achieve that goal
exec {'VeryLongExec':
command => template("${module}/verylongexec")
}
Then put the actual command in that template file
Credits should go to Jan Vansteenkiste to figure
I have a bat file that I should use to delete a part of one file and save into another one. I need to delete all the symbols between text "[aaa bbb]" and "[ccc ddd]". That is if I have the text:
[aaa bbb]
1
2
3
[ccc ddd]
I should have as output:
[aaa bbb]
[ccc ddd]
Thank you
EDIT: I would like to clarify the question. I should delete all the symbols between marker1 and marker2. Marker1 and marker2 are just some words or parts of text but not obligatory lines. For example I would have:
[aaa bbb] [ccc]
1
2
3
4
5
[www yyy]
If I want to delete the text between [aaa bbb] and [www yyy] I should have as output:
[aaa bbb]
[www yyy]
Take a look at the section "Delete between marker 1 and marker2" on this sed hints page
Applying it on your example. clean.sed:
/^\[aaa bbb\]$/,/^\[ccc ddd\]$/{
/^\[aaa bbb\]$/!{
/^\[ccc ddd\]$/!d
}
}
Run using:
sed -f clean.sed inputfile.txt
To edit the input file "in place", use the -i option to sed:
sed -i.bak -f clean.sed datafile.txt
A backup copy of the file with the name "datafile.txt.bak" is saved before editing the original.
EDIT: Since the assumption that the markers where always on a line of their own was wrong, heres a script that can handle markers in the middle of a line:
/\[aaa bbb\]/,/\[ccc ddd\]/{
s/\[aaa bbb\].*/[aaa bbb]/
s/.*\[ccc ddd\]/[ccc ddd]/
/\[aaa bbb\]$/!{
/^\[ccc ddd\]/!d
}
}
For this input:
foo[aaa bbb]1
2
3
4
5[ccc ddd]bar
foo
[aaa bbb]
1
2
3
[ccc ddd]
bar
It produces:
foo[aaa bbb]
[ccc ddd]bar
foo
[aaa bbb]
[ccc ddd]
bar
Note! It can't handle files where the markers can appear on the same line.
EDIT again: If the input format for marker 1 is such that you can always count on it being on a line of its own you can simplify the script some:
/^\[aaa bbb\]$/,/\[ccc ddd\]/{
s/.*\[ccc ddd\]/[ccc ddd]/
/^\[aaa bbb\]$/!{
/^\[ccc ddd\]/!d
}
}
(Anchoring marker 1 at the beginning and end of a line and skipping the trimming of the marker 1 line.)
Note that sed is available for Windows, along with a whole bunch of other GNU utilities. I'm not sure if you're asking whether there's an equivalent, or how to actually do it once you've got the tool.
D:\tmp\sed.exe -f sedscript.sed D:\tmp\test.txt >c:\tmp\test2.txt
/^\[Product Feature\]$/,/^\[Dm$/{
/^\[Product Feature\]$/!{
/^\[Dm$/!d
}
}
I looked at cmd and at power shell - can't find anything useful. Get yourself ActivePerl?
If you trust the VB script "sed-like" of this answer...
sed.vbs:
Dim pat, patparts, rxp, inp
pat = WScript.Arguments(0)
patparts = Split(pat,"/")
Set rxp = new RegExp
rxp.Global = True
rxp.Multiline = False
rxp.Pattern = patparts(1)
Do While Not WScript.StdIn.AtEndOfStream
inp = WScript.StdIn.ReadLine()
WScript.Echo rxp.Replace(inp, patparts(2))
Loop
You can type
cscript /Nologo sed.vbs s/^\d+\s*$/ < in.txt (in.txt being your initial text)
and you will obtain the expected output...
^\d+\s*$
Would target any line beginning with one or more digit, followed by 0 or more spaces within one line.
That is not the best "pure sed" solution and it can not actually delete lines, but this is a native "vista-compliant" solution...
Actually, the following hack deliberately interpreting the "d sed-command" could be able to 'delete' lines:
Dim pat, patparts, rxp, inp
pat = WScript.Arguments(0)
patparts = Split(pat,"/")
Set rxp = new RegExp
rxp.Global = True
rxp.Multiline = False
rxp.Pattern = patparts(1)
Do While Not WScript.StdIn.AtEndOfStream
inp = WScript.StdIn.ReadLine()
out = rxp.Replace(inp, patparts(2))
if not patparts(2)="d" or not out="d" Then
WScript.Echo out
end if
Loop
cscript /Nologo sed.vbs s/^\d+\s*$/ < in.txt would actually produce:
[aaa bbb]
[ccc ddd]
In a .bat, you could have a sed.bat:
cscript /Nologo sed.vbs %1 < %2
and then execute that .bat like this:
C:\prog\sed>sed.bat s/^\d+\s*$/d in.txt