I'm currently trying to do some basic cleaning on a pdf so I can convert it to ePub for use on my e-reader. All I'm doing is removing page numbers (easy) and footnotes (stumped so far). Basically, I'd like an expression that finds the tag pattern at the beginning of every footnote ( &lt;bar&gt; followed by a newline, a number, and either a letter or a quotation mark), selects the pattern and everything after it until it reaches the &lt;hr/1&gt; tag at the beginning of the next page. Here's some sample text: The phantoms, for so they then seemed, were flitting on the other side of &lt;br&gt; the deck, and, with a noiseless celerity, were casting loose the tackles and bands &lt;br&gt; of the boat which swung there. This boat had always been deemed one of the spare boats &lt;br&gt; technically called the captain’s, on account of its hanging from the starboard quarter.&lt;br&gt; The figure that now stood by its bows was tall and swart, with one white tooth &lt;br&gt; evilly protruding from its steel-like lips. &lt;br&gt;  &lt;br&gt; 1 &quot;Hardly&quot; had they pulled out from under the ship’s lee, when a &lt;br&gt; fourth keel, coming from the windward side, pulled round under the stern, &lt;br&gt; and showed the five strangers &lt;br&gt; 127 &lt;br&gt; &lt;br&gt; &lt;hr/&gt;  Since all of the footnotes are formatted this way, I want to select every group of lines that begin with  &lt;br&gt; (note the space) and end with the &lt;hr/&gt; tag. This is my first time really trying to use regex, so I've tried to hack together some attempts at solutions:  \s&lt;br&gt;\n\d+\s[a-zA-Z“].*: This correctly selects  &lt;br&gt; and the first line of the footnote, but stops at the break. \s&lt;br&gt;\n\d+\s[a-zA-Z“].*\n.*\n.*\n.*\n.*\n.* selects the correct number of lines, but this will obviously only work for footnotes that happen to have three lines of text.  \s&lt;br&gt;\n\d+\s[a-zA-Z“]((.*\n)*)&lt;hr\/&gt; starts at the correct place at the first footnote, but then ends up selecting the entirety of the rest of the document. My interpretation of this expression is &quot;start with  &lt;br&gt;, a number followed by a space followed by a letter or quotation mark, then select everything including newlines until you reach &lt;hr/&gt;.&quot;  \s&lt;br&gt;\n\d+\s[a-zA-Z“]((?:.*\r?\n?)*)&lt;hr\/&gt;\n same idea as (2), with the same result, though I am not familiar enough with regex to quite understand what is going on with this one.   Basically, my problem is that my expressions either exclude newlines (and ignores the end pattern) or it include every newline and returns the entirety of the text (and obviously still ignores the ending pattern. How do I get it to return just the text between the patterns, including the newlines?
3211
I have this gigantic ugly string: J0000000: Transaction A0001401 started on 8/22/2008 9:49:29 AM J0000010: Project name: E:\foo.pf J0000011: Job name: MBiek Direct Mail Test J0000020: Document 1 - Completed successfully  I'm trying to extract pieces from it using regex. In this case, I want to grab everything after Project Name up to the part where it says J0000011: (the 11 is going to be a different number every time). Here's the regex I've been playing with: Project name:\s+(.*)\s+J[0-9]{7}:  The problem is that it doesn't stop until it hits the J0000020: at the end. How do I make the regex stop at the first occurrence of J[0-9]{7}?
66905
I'm trying to have some clickable footnotes within tables. I tried using \footnote{}, it does create a link but there's no footnote text associated with it. \footnotemark[number] along with \footnotetext[]{} does create a fotenote but then there's no hyperlink. (I would like to make it clear that I'm trying to have footnotes at the bottom of the page and not footnotes within the table.)  Here's a small code snippet:  \documentclass{report}  \usepackage{hyperref} \begin{document}  \begin{table}[h!]     \centering     \begin{tabular}{|r|r|r|}         \hline         A\footnote{Test!} &amp; B\footnotemark[4] &amp; C\footnotemark[5]\\         \hline         123 &amp; Tim &amp; Jane\\         \hline         456 &amp; Tom &amp; Jung\\         \hline     \end{tabular}     \caption{A table} \end{table}  This is a clickable footnote\footnote{You clicked me!}.  \footnotetext[4]{This is B} \footnotetext[5]{This is C}  \end{document}
21454
When mousing over a link to a question on the main page, a tooltip appears with the first few sentences of the question.  When a question includes a picture or quote in those first sentences, this leads to weird spacing in the tool tip. It doesn't matter where specifically the picture or quote is in the first few sentences, of course. Update: Further testing shows this weirdness also happens with Lists (bulleted at least) and Video Embeds (On Movies.SE)  For comparison, how a normal paragraph break is shown:        Single line break.   Picture as first paragraph in question:        Notice the double blank line.   Quote, as second paragraph:        Notice the triple line before and after the quoted text.   List as first paragraph:        Single unneeded line break.   Youtube/Flash Embed as first paragraph on Movies.SE"        This actually two issues, as for some reason embedding a video leads to the system rendering the question as having a &lt;p&gt; followed by the video &lt;div&gt; followed by another &lt;p&gt;.   I thought it may have had to do with how paragraph html marks are parsed, but the block quotes do not use &lt;p&gt; or &lt;/p&gt;. Instead they use &lt;blockquote&gt;  The same issue happens if the picture is 1st, 2nd or 3rd paragraph, if the text of the question is short enough for those to be included.  Can this be fixed? It's on multiple stacks (First example is EE.SE, second is here on Meta.SE)  Update: I looked at the source for the page, and the rendered title tag for the second example () is  &lt;h3&gt;&lt;a href="/questions/274319/golden-tag-badge-owner-can-insta-close-questions-not-originally-tagged-with-a-ta" class="question-hyperlink" title="As explained here (emphasys mine):      You can instantly close as a duplicate any question that was originally asked with a tag you have a gold badge for.    But golden tag badge owner can ..."&gt;Golden tag badge owner can insta-close questions not originally tagged with a tag they own a golden badge for [duplicate]&lt;/a&gt;&lt;/h3&gt;   Four line breaks (New Line characters) just dumped in. The fix would be easy. Eliminate multiple New Lines in a row when rendering the Title attribute. A better fix, include spaces in that. That question actually has 3 new lines, space, 1 new line, and then new line, 2 spaces, 3 new lines. Should be simple to implement, I'd think.
116796
I want to remove the newline between two html tags which exists as follows:  &lt;font&gt; &lt;/font&gt;   I want to remove the newline character such that it becomes:  &lt;font&gt;&lt;/font&gt;   Also, there might be cases where there are more than one newline(s):  &lt;font&gt;  &lt;/font&gt;   That also I want to remove to make it look like:  &lt;font&gt;&lt;/font&gt;   One more scenario,  if the pattern is like:  &lt;font&gt; This is a text &lt;/font&gt;   After, conversion it should become:  &lt;font&gt;This is a text&lt;/font&gt;   All the above scenarios are resolved, if we just truncate only the newline between two html tags. We should not be considering any white spaces.  There are couple of ways I have found it using sed, but it is very time consuming and very very efficient performance wise, particularly if the file has 1000+ html tags.
109296
Problem  I have various footnotes, which are hyperlinked from the text to the bottom of their respective pages. When I click on the hyperlinks (in the main text), they always take me to the first page of my document. I also have footnotebackref which puts a hyperlink at the footnote to take the reader back to the main body of text and these links for fine.   Edited MWE  After a lot of deletion, I have managed to reduce the document to the following lines. One might say that I have found the problem, since the removal of \usepackage[hang, flushmargin]{footmisc} stops the problem, but I would still like to have non-indented footnotes.  \documentclass{article}  \usepackage[usenames,dvipsnames]{color} \usepackage[colorlinks=true]{hyperref}  \usepackage[hang, flushmargin]{footmisc}         %Problem line. \usepackage{footnotebackref}  \begin{document} \tableofcontents             \newpage                 \section{Section} This is some text\footnote{This is a footnote.}. \end{document}
1514
On the main site, you can (for example) ignore tags using this notation [tag:foo*], which will ignore stuff tagged as  but also .  The nice markdown highlighter for tags seems to have a problem with asterisks, though -- as you can see in this post.  I would have expected them to be highlighted the same way as they are on the front page.
63558
This is a question that arose in the comments here:   I normally hide footnotes from the TOC by doing this:  \section[title]{title\footnote{This is a footnote.}}.   This works in a lot of document classes (memoir, article, ...), but not in all of them. amsbook, for example, uses the optional argument only for the running heads so the footnote mark still ends up in the TOC. So what is the 'universal solution'?
22215
I would like to produce a document where I can display the first and last items of each two page spread in the headers of both the left and right pages. I know I can use \markboth{}{} to collect the usual form of marks that feed \leftmark and \rightmark. But that is limited to the text of one page at a time.  There doesn't appear to be a natural way to use the forward reference mechanism to do this, but there must be a trick, right?
120764
Using the command   \newcommand\@makefntext[1]{% \noindent\makebox[.02\columnwidth][l]{\@thefnmark}% \parbox[t]{.98\columnwidth}{#1}}   I got the desired result for the foot notes, as shown in the image below.   I'd like to know if my code is the best way to do this.    edited: using footmisc with the option hang as suggested, the format of the foot number is different so the vertical space around the foot note is changed.
8341
I'm going to submit form using cURL, where some of the contents is come from other file, selected using sed  If param1 is line matching pattern from other file using sed, below command will works fine:  curl -d param1="$(sed -n '/matchpattern/p' file.txt)" -d param2=value2 http://example.com/submit   Now, go to the problem. I want show only text between 2 matching pattern excluding the matching pattern itself.  Lets say file.txt contains:  Bla bla bla firstmatch It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. secondmatch The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English.   Currently, lots of "beetween 2 matching pattern" sed command won't remove firstmatch and secondmatch.  I want the result to become:  It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.
13695
If I try to put something like this into a question or answer  &lt;!-- &lt;br&gt;s are important here --&gt;   the first &gt; after the "br" is matched to the first &lt; before the "!--", resulting in this being displayed:     s are important here -->   This happens in both previews and actual posts. I'd say it's a bug.  HTML comments shouldn't be treated as regular HTML tags; &lt;!-- should only be matched to --&gt;.
61489
I am looking for a regex statement that will let me extract the HTML content from just between the body tags from a XHTML document.  The XHTML that I need to parse will be very simple files, I do not have to worry about JavaScript content or &lt;![CDATA[ tags, for example.  Below is the expected structure of the HTML file is that I have to parse. Since I know exactly all of the content of the HTML files that I am going to have to work with, this HTML snippet pretty much covers my entire use case. If I can get a regex to extract the body of this example, I'll be happy.  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;   &lt;head&gt;     &lt;title&gt;     &lt;/title&gt;   &lt;/head&gt;   &lt;body contenteditable="true"&gt;     &lt;p&gt;       Example paragraph content     &lt;/p&gt;     &lt;p&gt;       &amp;nbsp;     &lt;/p&gt;     &lt;p&gt;       &lt;br /&gt;       &amp;nbsp;     &lt;/p&gt;     &lt;h1&gt;Header 1&lt;/h1&gt;   &lt;/body&gt; &lt;/html&gt;   Conceptually, I've been trying to build a regex string that matches everything BUT the inner body content. With this, I would use the C# Regex.Split() method to obtain the body content. I thought this regex:  ((.|\n)*&lt;body (.)*&gt;)|((&lt;/body&gt;(*|\n)*)   ...would do the trick, but it doesn't seem to work at all with my test content in RegexBuddy.
73194
I'm trying to prepare html for conversion to an epub and have encountered a couple of problems that I would appreciate help with. Hope mixing a couple of related questions in a single post is OK.  The easiest is the quotation environment doesn't indent both margins (and not enough on the left). I've written a .cfg file and think I have that one solved. Here's what I'm using:  \Preamble{html} \begin{document} \Css { .quotation { margin-bottom:0.25em; margin-top:0.25em; margin-left:4em; margin-right:4em } } \EndPreamble   The next is figures and tables. tex4ht inserts an hr tag before and after the table. This is not part of the css, it's a separate tag generated by tex4ht. I haven't found where one customizes this. I can delete these in emacs from the html, but that doesn't seem the right way to do this. Here's a fairly minimal example showing the rules (and the quotation indent as well).  \documentclass{book}  \begin{document}  \chapter{Simple Example}  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla.  \begin{quotation} Default book style icreases the left and right margins for quotations by a noticeable amount. The css generated by tex4ht only increases the left margin by one em. The attached .cfg increases this to 4 em.  \end{quotation}  Sed lectus. Integer euismod lacus luctus magna. Quisque cursus, metus vitae pharetra auctor, sem massa mattis sem, at interdum magna augue eget diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi lacinia molestie dui. amet mauris.  \begin{table} \begin{center} \hbox{ \begin{tabular}{|l|c|c|}\hline entry1&amp;entry2&amp;entry3\\ entry4&amp;entry5&amp;entry6\\ \hline \end{tabular}} \end{center} \caption{a caption} \end{table}   Morbi in dui quis est pulvinar ullamcorper. Nulla facilisi. Integer lacinia sollicitudin massa. Cras metus. Sed aliquet risus a tortor.   \end{document}   [Edit 2] I'm pretty sure the hr tag is being generated for all floats. By trial and error I found my way to the html4.4ht file, which contains this code:  \Configure{float}    {\ifOption{refcaption}{}{\csname par\endcsname\ShowPar \leavevmode}}    {\:xhtml{\IgnorePar\EndP}\HCode{&lt;hr class="float"\xml:empty&gt;&lt;div      class="float"\Hnewline&gt;}}    {\ifvmode \IgnorePar \fi\EndP     \HCode{&lt;/div&gt;&lt;hr         class="endfloat" /&gt;}\csname par\endcsname\ShowPar}   On the assumption that the \HCode macro defines the html output, I removed the hr tag:  \Configure{float}    {\ifOption{refcaption}{}{\csname par\endcsname\ShowPar \leavevmode}}    {\:xhtml{\IgnorePar\EndP}\HCode{&lt;div      class="float"\Hnewline&gt;}}    {\ifvmode \IgnorePar \fi\EndP     \HCode{&lt;/div&gt;}\csname par\endcsname\ShowPar}   When I run htlatex with this config file, I get an error on a \begin{center} that is within a begin{table}. Without this change to the config file it runs fine, it has something to do with the edit, but since I don't really understand what's going on here, I'm utterly baffled as to how to fix it.  [End Edit 2]  [Edit 3]  The problem is not the change to the \Configure statement, but the presence of the \Configure statement in the .cfg file. Even if I copy the \Configure statement verbatim, I still get an error when \begin{center} is encountered. The error is "Missing $ inserted"  [End Edit 3]  The captions for figures and tables are not on the float page, but follow immediately on the next page after conversion to epub. Is this an html problem that can be fixed in tex4ht, or is it a problem in how Calibre is interpreting the html?  (updating to the current version of Calibre fixed this)  Should I be producing xhtml instead of html?  I'd be grateful for a pointer to good documentation about customizing tex4ht.
119008
Given this string:  SET @text = "&lt;a href=""https://salesforce.stackexchange.com""target=""_blank""&gt;Salesforce&lt;/a&gt; &lt;a href=""https://stackoverflow.com"" target=""_blank""&gt;Everything else&lt;/a&gt;"   And this function:  SET @matching = '\s+(?:[^&gt;]*?\s+)?href="([^"]*)"' SET @output = RegExMatch(@text, @matching, 1)   How can I manage to find and print an arbitrary number of matches in my string? E.g. in above example, I would like to present e.g. a rowset with each URL in each row.
42238
This code won't compile:  \documentclass{article} \usepackage{listings} \lstset{     language=C,     basicstyle=\small }  \begin{document} lorem ipsum\footnote{% \begin{lstlisting} // some C code or whatever... printf("Blah blah\n"); \end{lstlisting}} \end{document}   It says Illegal parameter number in definition of \lst@insertargs. I know listings is really picky about where it goes, but there must be a way to cram a listing into a footnote, right?  (This is a MWE and my tex files are a bit more complex; my actual error is Paragraph ended before \lst@next was complete. but they are hopefully related; I couldn't get this error with the MWE.)
97536
My vf page     &lt;apex:page renderAs="pdf" Controller="testpdf1"&gt;     &lt;head&gt;         &lt;style type="text/css" media="print"&gt;             @page              {                 size: 8.5in 11in;/* width height */             }              @page              {                 @top-center                  {                     content: element(header);                 }                  @bottom-left                  {                     content: element(footer);                 }             }              div.header              {                 padding: 10px;                 position: running(header);             }              div.footer              {                 display: block;                 padding: 5px;                 position: running(footer);             }              .pagenumber:before              {                 content: counter(page);             }              .pagecount:before              {                 content: counter(pages);             }         &lt;/style&gt;     &lt;/head&gt;      &lt;div class="header"&gt;             &lt;div align="right"&gt;Header&lt;/div&gt;     &lt;/div&gt;      &lt;div class="footer"&gt;         &lt;div&gt;Page &lt;span class="pagenumber"/&gt; of &lt;span class="pagecount"/&gt;&lt;/div&gt;     &lt;/div&gt;      &lt;div class="content"&gt;         &lt;p&gt;             &lt;apex:repeat value="{!opp}" var="item"&gt;                 &lt;tr&gt;                     &lt;td class="tableContent"&gt;{!item.Name}&lt;/td&gt;                 &lt;/tr&gt;             &lt;/apex:repeat&gt;         &lt;/p&gt;     &lt;/div&gt; &lt;/apex:page&gt;   Controller  public class testpdf1 {     public list&lt;Account&gt; opp{get;set;}      public testpdf1()     {         opp=[SELECT Name  from Account limit 50];     } }   I am getting all records in pdf format but able to get header in first page only and i am not getting header from second pages how can i display header to all pages.
111986
How could I position the epigraph in the end of the page, instead of at the beginning? I'm using this preamble:  \documentclass[pdftex,11pt,a4paper,openany]{memoir} \usepackage[brazil]{babel} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{indentfirst} \usepackage{latexsym} \usepackage{amsmath,amssymb,amsfonts,wasysym} \usepackage[pdftex]{graphicx} \usepackage{wrapfig} \usepackage[left=3cm,right=2cm,top=3cm,bottom=3cm]{geometry} \usepackage{color} \usepackage[dvipsnames]{xcolor} \definecolor{darkgray}{gray}{0.3} \setcounter{secnumdepth}{3} \setcounter{tocdepth}{3} \usepackage[pdftex, colorlinks=true, linkcolor=darkgray, citecolor=blue, urlcolor=blue]{hyperref}   and this commands on the page intended to the epigraph:  \thispagestyle{empty} \epigraph{O problema dessas citações na internet é a dificuldade para saber se elas são realmente autênticas.}{Friedrich Nietzsche}   I already tried to use \vspace{} and \vfill, and they dont work.