LaTeX: cite with [ ] argument in caption - arguments

I need the source of images listed in the "list of figures".
To do this I want to cite inside the caption argument:
This works:
\caption[Plan,\protect\cite{damluji1992}]{Plan}
This works too but i need it in the caption argument like in the next example:
\cite[p.156]{damluji1992}
I need this which doesn't work:
\caption[Plan,\protect\cite[p.156]{damluji1992}]{Plan}
it gives me the error "Argument of \HAR#dcite has an extra }."
In the *.lof file the corresponding line looks like this:
\contentsline {figure}{\numberline {2}{\ignorespaces Plan, \cite [S.156}}{5}{figure.caption.4}
-> the cite argument in { } is missing!
Without the cite argument in [ ] it looks like this:
\contentsline {figure}{\numberline {2}{\ignorespaces Plan, \cite {damluji1992}}}{5}{figure.caption.4}

I stumbled on this page with the same question and then found the answer at http://www.latex-community.org/forum/viewtopic.php?f=50&t=6225
The solution: put curly braces around the cite command:
{\cite[Theorem~2]{mEtAl}}
The reason this is necessary is that you have an optional [] argument inside another optional [] argument.

In preamble:
\usepackage{caption}[2011/11/10]
\newcommand{\figsource}[1]{%
\addtocounter{figure}{-1}
\captionlistentry{source: #1}
}
in document:
\begin{figure}
\includegraphics...
\caption{whatever}
\figsource{whatever-source}
\end{figure}
produces:
List of Figures
1.1 whatever . . . . . . . . 29
1.1 whatever-source: . . . . 29

Related

Json Extractor | How to avoid initial few lines

I have json path extractor and its response (given below), using match No.-1
#..[?(#.unitName == 'Prod')].name
My Json path giving the output as
Result[0]= Jon
Result[1]= Flip
Result[2]= Athar
Result[3]= Bobby
Result[4]= Azra
Result[5]= Colton
Result[6]= Sony
.
.
.
.
Result[1000]= Maik
I want to avoid first few lines randomly for each user .
Ex : For user 1 if first three lines are randomly ignored, the output should be as follows :
Result[0]= Bobby
Result[1]= Azra
Result[2]= Colton
Result[3]= Sony
.
.
.
.
Result[997]= Maik
I tried following expressions but it doesnt work
#..[?(#.unitName == 'Prod')].name[$ {__Random (1,500)}]
OR
#..[?(#.unitName == 'Prod')].name[299]
Maybe you should try considering switching to JSON JMESPath Extractor, there you could do something like:
[?unitName=='Prod'].name | #[3:6]
More information:
JMESPath - Filters and Multiselect Lists
JMESPath - Slicing
How to Performance Test Web Services Using JMeter

Initializing a matrix using a list with a string in it

Here is my code:
extensions [matrix]
..
sources-own[keyword1 keyword2 keyword3 keyword4 extrinsic-fitness visits]
..
to setup
create-sources
ask source 0 [
set keyword1 (matrix:from-row-list [["cat"][2]])
]
...
..
.
Now, when I click on SETUP and inspect "source 0", it shows the matrix to be initialized as the following:
{{matrix: [ [ 0 ][ 2 ] ]}}
Try as I might, I cannot get it to accept the string "cat" in place of the "0" in the first column.
OK, I got it.
A matrix in Netlogo can only hold numbers. One needs to use a "list" instead.

How to modify the href of a Ruby Mechanize::Page::Link before clicking it

I have a page retrieved using a Mechanize session and I need to click on a Mechanize::Page::Link as in this example:
my_link = #session.page.link_with(:id => "aPageLink")
# my_link.class == Mechanize::Page::Link
.
.
.
#session.click(my_link)
However, I need to modify the uri used in the link before it is clicked.
my_link = #session.page.link_with(:id => "aPageLink")
# my_link.class == Mechanize::Page::Link
.
.
.
# modify my_link here
.
.
.
#session.click(my_link)
How would I do that?
I should add that I've tried the following already [should have mentioned these earlier then some unrelenting soul wouldn't have marked down my question!]...
my_link.href = "my/modified/uri"
my_link['href'] = "my/modified/uri"
Solution from pguardiario's suggestion is as follows.
my_link = #session.page.link_with(:id => "aPageLink")
# modify my_link
modified_link = my_link.href
modified_link.sub!(/modification/, '')
# #session.click(my_link) <-- now replaced with following line
#session.get modified_link, [], my_link.referer
Many thanks!

How to get the return code of a shell script in lua?

I'm executing a script in lua:
os.execute("sh manager/scripts/update_system.sh" .. " " .. f)
And I want to get the output of the script( if exit status is 7 returns 7).
I tried
local output = os.execute("sh manager/scripts/update_system.sh" .. " " .. f)
print(output)
but it returns some weird numbers like 512
Any idea how to resolve this?
It seems like the outputs of os.execute are all 256 multiples. Don't ask me why, it must be a bug.
So I did this:
local exit = os.execute("sh manager/scripts/update_system.sh" .. " " .. f)
local value = exit / 256
print(value)
It works but I wonder if there is another solution.
This works for both Lua 5.1 and Lua 5.2
exit_code = io.popen'your_command \necho _$?':read'*a':match'.*%D(%d+)'+0

Sugarcrm / Suitecrm smarty preg_replace

Ive got the error below
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in C:\xampp\htdocs\suitecrm\include\Smarty\Smarty_Compiler.class.php on line 268
I have changed the PHP.ini file to stop showing deprecated errors, but it still shows up
error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT
I've also changed the line in the Smarty_Compiler.class
$source_content = preg_replace_callback($search, create_function ('$matches', "return '"
. $this->_quote_replace($this->left_delimiter) . 'php'
. "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'"
. $this->_quote_replace($this->right_delimiter)
. "';")
, $source_content);
But its not working..
Please advise
I found that and it seems working:
Replace lines from line 262 with:
/* replace special blocks by "{php}" */
$source_content = preg_replace_callback($search,
function($m) {
return "{php ".str_repeat("\n", substr_count($m[0], "\n"))."}";
},
$source_content);
I have resolved this issue by replacing the code in include/Smarty/Smarty_Compiler.class.php file. I replaced the code on line numbers from 262 to 268 with the below mentioned code. After that delete all the files which are in the cache folder and reload the page. This issue will be resolved.
/* replace special blocks by "{php}" */
$source_content = preg_replace_callback($search, create_function ('$matches', "return '"
. $this->_quote_replace($this->left_delimiter) . 'php'
. "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'"
. $this->_quote_replace($this->right_delimiter)
. "';")
, $source_content);
My solution:
$source_content = preg_replace_callback($search,
function($m) {
return $this->_quote_replace($this->left_delimiter) .
"php ".str_repeat("\n", substr_count($m[0], "\n")) .
$this->_quote_replace($this->right_delimiter);
},
$source_content);
In solution from Axel De Acetis I miss using of function $this->_quote_replace.
In solution from Sandeep Shivhare I dont like the number 1 in $matches[1], it references wrong string.

Resources