I tried to incorporate some equations into a wordpress blog entry. No special installation, just using the version of mathjax Wordpress comes with.
My paragraph reads
This action is invariant under conformal symmetries of the worldsheet
$latex z \to z + \sum_{n = -\infty}^\infty \epsilon_n z^{n+1} $ , where $latex z$
parameterizes the worldsheet. In 2 dimensions, the conformal group is especially large and > there are infinitely many generators $latex \l_n: z \to z + \epsilon_n z^{n+1} $ .
Both equations give a "formula does not parse". Only the "z" renders correctly. If I put this into a latex document, the formula compile. Can you explain?
The FAQ page gives hints, but does not resolve my problem. The hints on the page do work.
Related
To say that I am a LaTeX amateur is an understatement, though by some miracle, I am managing to write my thesis in it. I am using RStudio to write and compile my thesis, due to all of my analysis being done in R and wanting the ability to insert dynamic plots etc.
As my thesis has increased in size, I wanted to break the chapters off into sub .Rnw files so that I could work on each chapter independently (with my need for R code within each chapter ruling out using .tex files). The only way I could get this to work, was using \Sexpr{knit_child('chapter.Rnw')}. I weave my files using knitr rather than Sweave as again, that is the only I can get it to compile correctly. Unfortunately, I've never managed to understand why!
Nevertheless, this is working very nicely, is much easier to manage and my plots and R code are compiling correctly, but my previously functioning \ref and \label commands no longer work. Well, they work within a chapter, but not between them.
I include my main document here and the latex commands that I think are relevant to my question. I have googled this all morning, but am getting nowhere alone.
\documentclass[12pt]{report} %What kind of document
\usepackage{titlesec} %can actually name chapters rather than having "Chapter 1" etc
\usepackage[backend=bibtex,style=authoryear-comp,sorting=nyt,maxcitenames=2,url=false]{biblatex}
\bibliography{library}
% ----------- KNITR SETUP ------------------------
<<setup, include=FALSE, cache=FALSE, echo=FALSE>>=
opts_chunk$set(fig.path='figures/plots-', fig.align='center', fig.show='hold', eval=TRUE, echo=TRUE)
options(replace.assign=TRUE,width=80)
# setwd("C:/Users/cainswor/Box Sync/Imperial/Reports/Thesis")
setwd("D:/BoxSync/BoxSync/Reports/Thesis")
data_loc <- "D:/BoxSync/BoxSync/Reports/Thesis/Data for Thesis"
Sys.setenv(TEXINPUTS=getwd(),
BIBINPUTS=getwd(),
BSTINPUTS=getwd())
x <- c("shiny","flowViz","nls2","plyr","RColorBrewer","abind","MASS","gplots","hexbin",
"data.table","fastmatch","stringr","hypergeo","rgl","mclust","knitr","dbscan")
lapply(x, require, character.only=T)
# Sweave2knitr('ThesisSecondDraft.Rnw')
#
\begin{document}
\Sexpr{knit_child('Th1_Introduction.Rnw')}
\part{The Experiment}
\Sexpr{knit_child('Th2_Characterisation.Rnw')}
\end{document}
Here is an example which work on my files.
In the main.Rnw document :
\documentclass{article}
\begin{document}
\SweaveOpts{concordance=TRUE}
Hello world
\SweaveInput{child_test.Rnw}
\end{document}
In the child_test.Rnw file
%!Rnw root = main.Rnw
\SweaveOpts{echo = TRUE, eval = TRUE}
\section{Analysis}
This is the analysis.
<<analysis, result = tex>>=
summary(cars)
#
First time markdown user (and LaTex novice).
I'm trying to insert inline formulas using single $ as I have seen demonstrated in several places, including the R Markdown Reference Guide - but it's not working.
inline equation test: $x \leq 5 $ not working
is simply output as
"inline equation test: $x 5 $ not working"
It works fine using $$ to create a new line, but any tips how to get it working inline would be much appreciated.
And as so often happens, as soon as I ask a question, the answer comes to me.
inline equation test: $x \leq 5 $ not working
has a space before the closing $ and does not work.
inline equation test: $x \leq 5$ not working
has the space deleted and works just fine.
I've been using Doxygen successfully to generate PDF documentation for a sizable Fortran 90 project since v1.6. After a recent upgrade to Doxygen 1.8, pdflatex is choking with an error I can't understand. From refman.log:
.
.
.
<use classfate__source_a022bf629bdc1d3059ebd5fb86d13b4f4_icgraph.pdf>
Package pdftex.def Info: classfate__source_a022bf629bdc1d3059ebd5fb86d13b4f4_ic
graph.pdf used on input line 607.
(pdftex.def) Requested size: 350.0pt x 65.42921pt.
)
(./classm__aerosol.tex
! Undefined control sequence.
<recently read> \LT#LL#FM#cr
l.25 ...1833ffa6f2fae54ededb}{ia\-\_\-nsize}), \\*
? ?
Type <return> to proceed, S to scroll future error messages,
R to run without stopping, Q to run quietly,
I to insert something, E to edit your file,
1 or ... or 9 to ignore the next 1 to 9 tokens of input,
H for help, X to quit.
Looking at the first 25 lines of classm__aerosol.tex, nothing obviously matches the error message:
\hypertarget{classm__aerosol}{\section{m\-\_\-aerosol Module Reference}
\label{classm__aerosol}\index{m\-\_\-aerosol#{m\-\_\-aerosol}}
}
Contains general aerosol-\/related constants and routines.
\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item
subroutine \hyperlink{classm__aerosol_aa06c1f39c6bd34f22be92d21535f0320}{aerdis} (I\-A\-E\-R\-O, M\-A\-E\-R\-O, V\-O\-L, A\-R\-E\-A, M\-U, T\-G\-A\-S, R\-H\-O, A\-G\-A\-M\-M\-A, X\-L\-A\-E\-R, D\-M\-E\-A\-N, N\-A\-E\-R, X\-N\-D\-A\-E\-R, L\-S\-D\-A\-E\-R)
\begin{DoxyCompactList}\small\item\em Return aerosol mass given a volume, based on aerosol size distribution function. \end{DoxyCompactList}\item
real(kind=wp) function \hyperlink{classm__aerosol_a2dff4ff413057e8788fba7270a30c093}{lamsed} (V\-O\-L, H, M\-U\-G, R\-H\-O\-A\-E\-R, A\-G\-A\-M\-M\-A, A\-C\-H\-I, A\-F\-E\-O, K\-O, M\-A\-E\-R, F\-M\-A\-E\-R, F\-A\-E\-R\-S\-S, F\-S\-E\-D\-D\-K)
\begin{DoxyCompactList}\small\item\em Calculate aerosol removal constant and interpolation factor between steady-\/state and decaying aerosol correlations. \end{DoxyCompactList}\item
pure real(kind=wp) function \hyperlink{classm__aerosol_a6d0a04004f49c404c67e0aa69dd39ee1}{fdbend} (V\-E\-L, H\-S\-E\-D, T\-G, R\-H\-O\-G, M\-U\-G, R\-H\-O\-P\-A\-R, C\-A\-E\-R\-O, X\-D\-B\-E\-N\-D, N90\-J)
\begin{DoxyCompactList}\small\item\em Find total impaction efficiency for aerosol deposition considering 90-\/degree bends in a flow path. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Public Attributes}
\begin{DoxyCompactItemize}
\item
integer, parameter \hyperlink{classm__aerosol_a8f604b7ffe3c1833ffa6f2fae54ededb}{ia\-\_\-nsize} = 30
\item
integer, parameter \hyperlink{classm__aerosol_ae71813ecf0c7768af9d6292efb14774f}{ia\-\_\-nmass} = 10
\item
real(kind=wp), dimension(\hyperlink{classm__aerosol_a8f604b7ffe3c1833ffa6f2fae54ededb}{ia\-\_\-nsize}), \\*
Nothing obviously matches the recently read chunk "\LT#LL#FM#cr" and I don't know enough low-level TeX to translate that into something that might actually be in the source text.
Suspecting this might have been fixed in a later version of Doxygen than the one shipping with Linux Mint (v1.8.1.2), I built & installed v1.8.3.1 from source, updated my doxyfile, blew away the old documentation and regenerated it. I get the same baffling error.
There's nothing obvious in refman.log that would indicate missing or broken LaTeX packages and I'm completely at a loss as to what's causing this.
As this still gets a hit on Google when you search:
doxygen missing $ inserted
I would like to add something.
Do not use a PROJECT_NAME containing underscores (_)!
After a brief look into the doxygen's current documentation (I am using 1.8.4) it does not make that explicit.
this will be difficult to solve unless you provide a bit more information - possibly using \errorcontextlines=9999 as suggested in the comments on the question.
as a first short though, the name of the control sequence that can't be found (i.e. \LT#LL#FM#cr) is one defined by the longtable package (documentation, p. 15) - thus adding:
\usepackage{longtable}
to the preamble of the document might help.
If so, according to the doxygen documentation here, adding the following to your configuration file should do the trick:
EXTRA_PACKAGES=longtable
I'm currently searching for an application or a script that does a correct word count for a LaTeX document.
Up till now, I have only encountered scripts that only work on a single file but what I want is a script that can safely ignore LaTeX keywords and also traverse linked files...ie follow \include and \input links to produce a correct word-count for the whole document.
With vim, I currently use ggVGg CTRL+G but obviously that shows the count for the current file and does not ignore LaTeX keywords.
Does anyone know of any script (or application) that can do this job?
I use texcount. The webpage has a Perl script to download (and a manual).
It will include tex files that are included (\input or \include) in the document (see -inc), supports macros, and has many other nice features.
When following included files you will get detail about each separate file as well as a total. For example here is the total output for a 12 page document of mine:
TOTAL COUNT
Files: 20
Words in text: 4188
Words in headers: 26
Words in float captions: 404
Number of headers: 12
Number of floats: 7
Number of math inlines: 85
Number of math displayed: 19
If you're only interested in the total, use the -total argument.
I went with icio's comment and did a word-count on the pdf itself by piping the output of pdftotext to wc:
pdftotext file.pdf - | wc - w
latex file.tex
dvips -o - file.dvi | ps2ascii | wc -w
should give you a fairly accurate word count.
To add to #aioobe,
If you use pdflatex, just do
pdftops file.pdf
ps2ascii file.ps|wc -w
I compared this count to the count in Microsoft Word in a 1599 word document (according to Word). pdftotext produced a text with 1700+ words. texcount did not include the references and produced 1088 words. ps2ascii returned 1603 words. 4 more than in Word.
I say that's a pretty good count. I am not sure where's the 4 word difference, though. :)
In Texmaker interface you can get the word count by right clicking in the PDF preview:
Overleaf has a word count feature:
Overleaf v2:
Overleaf v1:
I use the following VIM script:
function! WC()
let filename = expand("%")
let cmd = "detex " . filename . " | wc -w | perl -pe 'chomp; s/ +//;'"
let result = system(cmd)
echo result . " words"
endfunction
… but it doesn’t follow links. This would basically entail parsing the TeX file to get all linked files, wouldn’t it?
The advantage over the other answers is that it doesn’t have to produce an output file (PDF or PS) to compute the word count so it’s potentially (depending on usage) much more efficient.
Although icio’s comment is theoretically correct, I found that the above method gives quite accurate estimates for the number of words. For most texts, it’s well within the 5% margin that is used in many assignments.
If the use of a vim plugin suits you, the vimtex plugin has integrated the texcount tool quite nicely.
Here is an excerpt from their documentation:
:VimtexCountLetters Shows the number of letters/characters or words in
:VimtexCountWords the current project or in the selected region. The
count is created with `texcount` through a call on
the main project file similar to: >
texcount -nosub -sum [-letter] -merge -q -1 FILE
<
Note: Default arguments may be controlled with
|g:vimtex_texcount_custom_arg|.
Note: One may access the information through the
function `vimtex#misc#wordcount(opts)`, where
`opts` is a dictionary with the following
keys (defaults indicated): >
'range' : [1, line('$')]
'count_letters' : 0/1
'detailed' : 0
<
If `detailed` is 0, then it only returns the
total count. This makes it possible to use for
e.g. statusline functions. If the `opts` dict
is not passed, then the defaults are assumed.
*VimtexCountLetters!*
*VimtexCountWords!*
:VimtexCountLetters! Similar to |VimtexCountLetters|/|VimtexCountWords|, but
:VimtexCountWords! show separate reports for included files. I.e.
presents the result of: >
texcount -nosub -sum [-letter] -inc FILE
<
*VimtexImapsList*
*<plug>(vimtex-imaps-list)*
The nice part about this is how extensible it is. On top of counting the number of words in your current file, you can make a visual selection (say two or three paragraphs) and then only apply the command to your selection.
For a very basic article class document I just look at the number of matches for a regex to find words. I use Sublime Text, so this method may not work for you in a different editor, but I just hit Ctrl+F (Command+F on Mac) and then, with regex enabled, search for
(^|\s+|"|((h|f|te){)|\()\w+
which should ignore text declaring a floating environment or captions on figures as well as most kinds of basic equations and \usepackage declarations, while including quotations and parentheticals. It also counts footnotes and \emphasized text and will count \hyperref links as one word. It's not perfect, but it's typically accurate to within a few dozen words or so. You could refine it to work for you, but a script is probably a better solution, since LaTeX source code isn't a regular language. Just thought I'd throw this up here.
I have some .rst files and I convert them to .tex file using standard sphinx converter.
In some .rst I have tables with special width like:
.. list-table::
:widths: 50 50
The resulting .tex always contains tables like:
\begin{tabulary}{\textwidth}{|L|L|}
So, the column width is lost.
How can I preserve column width when converting rst to latex?
I used comma separator too,
.. list-table::
:widths: 50 , 50
:header-rows: 1
* - SETTING
- DESCRIPTION
* - Enable
- Enables or disables internal tracing.
* - Verbose
- Enables or disables extended internal tracing.
but it doesn't work.. maybe I used a bad converter? What converter do you recommend?
actually the command
.. tabularcolumns:: |p{4.5cm}|p{8.5cm}|
is needed just before .. list-table::
https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-tabularcolumns
try:
:widths: 50, 50
with a comma separator.
The output also depends on how your table is written in rst.
I assumed that you were using the standard rst table syntax, not making tables from bulleted lists (as is possible). For more help, try http://docutils.sourceforge.net/docs/ref/rst/directives.html#tables
Also, if the 50, 50 is the column width, your latex code should look like this:
\begin{tabulary}{ 1\textwidth}{ | p{0.5} | p{0.5} | }
and:
\begin{tabulary}{total width of table}{| column width| column width|}
The docutils rst2latex writer has some issues with tables: http://docutils.sourceforge.net/docs/dev/todo.html#tables , so maybe your problem is related to that? I think the Sphinx writer is based on rst2latex and might thus have the same issues.
I can confirm that this:
.. list-table::
:widths: 10 40 50
* - Module
- Link
- Description
Works with rst2latex
\setlength{\DUtablewidth}{\linewidth}
\begin{longtable*}[c]{|p{0.104\DUtablewidth}|p{0.375\DUtablewidth}|p{0.465\DUtablewidth}|}
\hline
Module
&
Link
&
Description
\\
\hline
But with sphinx, I get what the OP put. So not an rst2latex issue I would gather.
The "Auto" width stuff the docs talk about is also not very functional for me, links tend to bleed over.
Since I have a huge documentation, I tried to fix the latex generation. Also, I consider Latex notation in rst files a disadvantage, because it's inconsistent and requires editors to partly learn a touchy markup language.
I replaced LaTeXTranslator.depart_table with my own version. I copied the original depart_table and added this code (shortened):
def my_depart_table (self, node):
totalColwidth = 0
givenColwidth = []
hasColwidth = False
for tgroup in node:
for tableColspec in tgroup:
try:
if tableColspec.has_key('colwidth'):
totalColwidth += tableColspec['colwidth']
givenColwidth.append(tableColspec['colwidth'])
hasColwidth = True
except:
print "colspec missing. \n"
# original code
if hasColwidth:
colspec = ""
for thisColwidth in givenColwidth:
colspec += ('>{\RaggedRight}p{%.3f\\linewidth}' % (0.95 * thisColwidth / totalColwidth))
#print "using widths: %.3f %s %s" % ((0.95 * thisColwidth / totalColwidth), thisColwidth, totalColwidth)
self.body.append('{' + colspec + '}\n')
# more original code
LaTeXTranslator.depart_table = my_depart_table
Im neither fluent in Python nor Sphinx, so use at own risk. I hope you get the idea or can even give advice.
If you use Python < 3.0 and want to remove the factor 0.95 completely, remember to either cast one of the integers to float or import division from __ future __.