I am using pgfsweave with Lyx 1.6.8 and xtable.
providing table captions by
<<result=tex>>=
print(xtable(<dataframe>,caption="Here is my caption"))
#.
How can I insert a label into the table caption that I can crossreference in the text from the lyx>Insert>Cross-reference menu?
I have tried to insert>float>table and inserted
print(xtable(<dataframe>,floating=FALSE)) and
"Here is my caption" in the Table caption inner frame
but this results in (literally):
[float Table:
<...Table ...>
[Table 2: "Here is my caption" ] ]
Even a barefoot workaround to crossreference
<<result=tex>>=
print(xtable(<dataframe>,caption="Here is my caption",label = "tab:one"))
#
from an ERT-box would help.
SOLVED:
Just use TWO arguments in the xtable-function call in the R-code:
xtable(<dataframe>
, caption = "My caption\\label{tab:MyTable1}"
,label="tab:MyTable1")
The \\label{tab:MyTable1} inside the caption is changed to
\label{tab:MyTable1} by R and then interpreted by LaTeX.
The argument label="tab:MyTable1" is ignored by R and therefore at your disposal to trick Lyx into allowing for crossreferencing to the label table label.
Use Insert>label to insert the label "tab:MyTable1" (excluding the quotes) here.
Related
I want to place my text so i can get something like:
"SomeText1
SomeText2 One ...
two ...
three ..."
And I need to customize each of sometexts and 1,2,3 separately.
So I use the code
Label{
...
textFormat: Text.RichText
text: <html><b><div style='font-size: 12pt;'> SomeText1</div></b></html>+
<html><i><div style='font-size: 12pt;'> SomeText2</div></i></html>+
(here must be a function which back some big text)
...
}
This code works great except one thing... It acts like ".simplefield()" and just "eat" all 2+ spaces and doesn't allow to use "\n". What can I do to change this?
I found the solution of my problem. When I type:
"1
2
3"
I see "1 2 3", but actually it is "1\n2\n3". My html-ed label doesn't react to "\n". So I just added a function in my .cpp, which replaced "\n" with "br". Here is it
str.replace("\n","<br>");
I am working on my second Python scraper and keep running into the same problem. I would like to scrape the website shown in the code below. I would like to be ability to input parcel numbers and see if their Property Use Code matches. However, I am not sure if my scraper if finding the correct row in the table. Also, not sure how to use the if statement if the use code is not the 3730.
Any help would be appreciated.
from bs4 import BeautifulSoup
import requests
parcel = input("Parcel Number: ")
web = "https://mcassessor.maricopa.gov/mcs.php?q="
web_page = web+parcel
web_header={'User-Agent':'Mozilla/5.0(Macintosh;IntelMacOSX10_13_2)AppleWebKit/537.36(KHTML,likeGecko)Chrome/63.0.3239.132Safari/537.36'}
response=requests.get(web_page,headers=web_header,timeout=100)
soup=BeautifulSoup(response.content,'html.parser')
table=soup.find("td", class_="Property Use Code" )
first_row=table.find_all("td")[1]
if first_row is '3730':
print (parcel)
else:
print ('N/A')
There's no td with class "Property Use Code" in the html you're looking at - that is the text of a td. If you want to find that row, you can use
td = soup.find('td', text="Property Use Code")
and then, to get the next td in that row, you can use:
otherTd = td.find_next_sibling()
or, of you want them all:
otherTds = td.find_next_siblings()
It's not clear to me what you want to do with the values of these tds, but you'll want to use the text attribute to access them: your first_row is '3730' will always be False, because first_row is a bs4.element.Tag object here and '3730' is a str. You can, however, get useful information from otherTd.text == '3730'.
I want to extract from following html code:
<li>
<a test="test" href="abc.html" id="11">Click Here</a>
"for further reference"
</li>
I'm trying to do with following extract command
response.css("article div#section-2 li::text").extract()
But it is giving only "for further reference" line
And Expected output is "Click Here for further reference" as a one string.
How to do this?
How to modify this to do the same if following patterns are there:
Text Hyperlink Text
Hyperlink Text
Text Hyperlink
There are at least a couple of ways to do that:
Let's first build a test selector that mimics your response:
>>> response = scrapy.Selector(text="""<li>
... <a test="test" href="abc.html" id="11">Click Here</a>
... "for further reference"
... </li>""")
First option, with a minor change to your CSS selector.
Look at all text descendants, not only text children (notice the space between li and ::text pseudo element):
# this is your CSS select,
# which only gives direct children text of your selected LI
>>> response.css("li::text").extract()
[u'\n ', u'\n "for further reference"\n']
# notice the extra space
# here
# |
# v
>>> response.css("li ::text").extract()
[u'\n ', u'Click Here', u'\n "for further reference"\n']
# using Python's join() to concatenate and build the full sentence
>>> ''.join(response.css("li ::text").extract())
u'\n Click Here\n "for further reference"\n'
Another option is to chain your .css() call with XPath 1.0 string() or normalize-space() inside a subsequent .xpath() call:
>>> response.css("li").xpath('string()').extract()
[u'\n Click Here\n "for further reference"\n']
>>> response.css("li").xpath('normalize-space()').extract()
[u'Click Here "for further reference"']
# calling `.extract_first()` gives you a string directly, not a list of 1 string
>>> response.css("li").xpath('normalize-space()').extract_first()
u'Click Here "for further reference"'
I use xpath if that is the case the selector will be:
response.xpath('//article/div[#id="section-2"]/li/a/text()').extract()#this will give you text of mentioned hyper link >> "Click Here"
response.xpath('//article/div[#id="section-2"]/li/a/#href').extract()#this will give you link of mentioned hyper link >> "abc.html"
response.xpath('//article/div[#id="section-2"]/li/text()').extract()#this will give you text of li >> "for further reference"
The extension tt_news is very useful for me but there is this little thingy called "register:newsMoreLink". This register does contain the singlePid of the contentelement (defined a single view page) and the uid of the newsarticle from the news extension.
This is the typoscript section of the "new ts" of the extension tt_news
As you can see there is "append.data = register:newsMoreLink"...
plugin.tt_news {
displayLatest {
subheader_stdWrap {
# the "more" link is directly appended to the subheader
append = TEXT
append.data = register:newsMoreLink
append.wrap = <span class="news-list-morelink">|</span>
# display the "more" link only if the field bodytext contains something
append.if.isTrue.field = bodytext
outerWrap = <p>|</p>
}
}
}
What is "register:newsMoreLink"? Is this like a function or something? I do not know. But "register:newsMoreLink" produces a strange link if I use this on "append.data". It produces are "More >" link. The "More >" link after a news article teaser looks like this:
http://192.168.1.29/website/index.php?id=474&tx_ttnews%5Btt_news%5D=24&cHash=95d80a09fb9cbade7e934cda5e14e00a
474 is the "singlePid" (this is what it calls in the database
24 is the "uid" of the news article (the ones you create with the tt_news plugin in the backend)
My question is: Where is the "register:newsMoreLink" defined? Is it defined generally or do I miss a fact of Typo3..? How can I add an anchor link at the end of this "More >" href? Like:
http://192.168.1.29/website/index.php?id=474&tx_ttnews%5Btt_news%5D=24&cHash=95d80a09fb9cbade7e934cda5e14e00a#myAnchor1
register:newsMoreLink is not a function. It's one of the data types. In other words a type of data that you can access with stdWrap.data. register is set with LOAD_REGISTER. Though, in case of tt_news this is set in the PHP code with $this->local_cObj->LOAD_REGISTER().
I'm afraid you cannot easily add an anchor to that link. However, you can set the append to create your own custom link to the news record using typolink:
append = TEXT
append {
value = text of the link
typolink {
# ...typolink configuration...
}
}
You shall be interested in the typolink's attributes parameter, additionalParams and section.
this is the code I use to link to an pid with a anchor target:
displayList.plugin.tt_news.subheader_stdWrap {
append = TEXT
append.data >
append {
value = mehr
typolink{
parameter = 47 // pid
section = entry_{field:uid} // anchor name
section.insertData = 1
}
}
I'm using Qwebkit and I like to be able to insert into html table each data input that comes last
as first record (<tr><td>...my data ...</td></tr>) in to the table.
Here is my code this is only example :
ui.webView->page()->mainFrame()->setHtml("<html><body><p>HTML Table Test</p>"
"<table id=\"mainTable\" name=\"mainTable\" BORDER=1 BORDERCOLOR=RED></table>"
"</body></html>");
QWebElement body = ui.webView->page()->mainFrame()->documentElement();
QWebElement mainTable = ui.webView->page()->mainFrame()->findFirstElement("#mainTable");
mainTable.appendInside ("<tr><td>1111111<\/td></\tr>"); ///<-- this is i like to be last in the end
mainTable.appendInside ("<tr><td>2222222<\/td></\tr>"); ///<-- this is i like to be in the middle
mainTable.appendInside ("<tr><td>3333333<\/td></\tr>"); ///<-- this is i like to be in the first
The content of the records are coming dynamically and not as I show here, so I can't do it hard coded; in short I need LIFO algorithm here ..
How should I do that ?
The QWebElement::appendInside method add the parameter to the end of the web element.
The QWebElement::prependInside method add the parameter to the beginning of the web element.
If we have a QWebElement *elt containing a empty table such as :
<table><table>
to create the following table,
<table>
<tr><td>A</td></tr>
<tr><td>B</td></tr>
<tr><td>C</td></tr>
</table>
You can use one of the two following methods, they are equivalent.
Method 1, with appendInside
elt->appendInside("<tr><td>A</td></tr>");
elt->appendInside("<tr><td>B</td></tr>");
elt->appendInside("<tr><td>C</td></tr>");
or method 2, with preprendInside
elt->prependInside("<tr><td>C</td></tr>");
elt->prependInside("<tr><td>B</td></tr>");
elt->prependInside("<tr><td>A</td></tr>");
Using prependInside or appendInside gives you the control over the FIFO or LIFO behaviour of your algorithm.