In a package, I have several vignettes that use mathematical notation, like:
This vignette illustrates the ideas behind solving systems of linear equations of the form $\mathbf{A x = b}$
where
- $\mathbf{A}$ is an $m \times n$ matrix of coefficients for $m$ equations in $n$ unknowns
- $\mathbf{x}$ is an $n \times 1$ vector unknowns, $x_1, x_2, \dots x_n$
- $\mathbf{b}$ is an $m \times 1$ vector of constants, the "right-hand sides" of the equations
When I compile the vignette using R Studio (Ctrl+Shift+K), it renders properly in the HTML file, whether viewed in the R Studio viewer or the browser.
Yet, when the package is submitted to CRAN, and the vignettes are built there from the source package, the math is not rendered properly, but appears as markup,
Is there something I need to add to my YAML header so that vignettes built outside of R Studio will render mathematics properly? Currently, I use just a standard header:
---
title: "Solving Linear Equations"
author: "Me"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Solving Linear Equations}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
The generated pandoc command from R Studio is
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS linear-equations.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output pandoc8141d044063.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template "C:\R\R-3.2.5\library\rmarkdown\rmd\h\default.html" --css "C:\R\R-3.2.5\library\rmarkdown\rmarkdown\templates\html_vignette\resources\vignette.css" --mathjax --variable "mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --highlight-style pygments
Perhaps I need to add a YAML option corresponding to --self-contained or --standalone ?
Posting years later in case another user has the same question. I noticed the same issues rendering equations in my vignettes---not on CRAN, just locally hosted packages. Ctrl + Shift + K rendered fine, but viewing with vignette() in the RStudio Help panel renders the equations badly.
I think this is just an issue that the Help panel doesn't render the HTML completely. If I view the packaged vignette in a browser, e.g. using RShowDoc(), then the equations are fine. So maybe users should be directed to RShowDoc() more often than vignette().
Related
for the purpose of creating a syllabus, I like to know whether it is possible to insert a citation as a full citation. Right now, I have following markdown code:
# Session 1
#zhu2015.
This converts (pandoc "document.md" -o "document.pdf" --from markdown --template "eisvogel" --listings --citeproc) in the pdf as
Session 1
Zhu and Basar (2015).
Bibliography
Zhu, Quanyan, and Tamer Basar. 2015. “Game-Theoretic Methods for Robustness, Security, and Resilience of Cyberphysical Control Systems: Games-in-Games Principle for Optimal Cross-Layer Resilient Control Systems.” Control Systems, IEEE 35 (1): 46–65.
However, would it be possible to insert the reference as a full-citation in text?
Such as:
Session 1
Zhu, Quanyan, and Tamer Basar. 2015. “Game-Theoretic Methods for Robustness, Security, and Resilience of Cyberphysical Control Systems: Games-in-Games Principle for Optimal Cross-Layer Resilient Control Systems.” Control Systems, IEEE 35 (1): 46–65.
Thanks for your help!
Here's how to do this with a Lua filter: First, the filter finds the generated bibliography entry and saves it to a table, indexed by the citation key. Then it looks for the citation and replaces it with the full entry.
local refs = {}
local function store_refs (div)
local ref_id = div.identifier:match 'ref%-(.*)$'
if ref_id then
refs[ref_id] = div.content
end
end
local function replace_cite (cite)
local citation = cite.citations[1]
if citation and refs[citation.id] and #cite.citations == 1 then
return pandoc.utils.blocks_to_inlines(refs[citation.id])
end
end
return {
{Div = store_refs},
{Cite = replace_cite},
}
Save the above to a file and pass that file to pandoc with the --lua-filter command line option. The filter must run after the citeproc processer has done its work, so it should be the last command line argument. Tested with the latest pandoc version 2.12 (which no longer requires pandoc-citeproc, but it should work either way).
How to display all the numbers from a given matrix in Euler Math Toolbox? It doesn't seem to show more than 8 columns at a time, which isn't enough as I frequently need to view more than that.
Output I'm getting as of now:
The documentation says:
Large matrices or vectors might not print in full size. To change this, toggle the behavior with:
largematrices on
largematrices off
or use the operator showlarge.
showlarge random(10,10)
See:
showlarge (Basic Utilities)
The link in the above documentation link directs here:
function prefix showlarge (x$)
Prints large matrices in full.
By default EMT eclipses lines and rows of large matrices. This can be used to see the full matrix. If the parameter is a variable the variable name will be printed.
The default can be changed with largematrices on/off.
x=random(20,5); showlarge(x)
showlarge(random(20,5))
See:
largematrices (Euler Core),
show (Maxima Documentation)
An example of detectSURFFeatures in comparison of 2 image is in below. I couldn't make detectSURFFeatures function work in my MATLAB. no help or doc detectSURFFeatures gives any clue. the error says " > UncalibratedSterio
Undefined function 'detectSURFFeatures' for input arguments of type 'uint8'." but the function itself can cover uint8 as i know. what should i do?
%Rectified Sterio Image Uncalibrated
% There is no calibration of cameras
I1 = rgb2gray(imread('right_me.jpg'));
I2 = rgb2gray(imread('left_me.jpg'));
Value = 2000.0;
blobs1 = detectSURFFeatures(I1, 'MetricThreshold', Value);
blobs2 = detectSURFFeatures(I2, 'MetricThreshold', Value);
figure;
imshow(I1);
hold on;
plot(selectStrongest(blobs1, 30));
title('Thirty strongest SURF features in I1');
figure;
imshow(I2);
hold on;
plot(selectStrongest(blobs2, 30));
title('Thirty strongest SURF features in I2');
You are getting that error because detectSURFFeatures does not exist in your MATLAB distribution. You must have at least R2011b, as that was when detectSURFFeatures was available: http://www.mathworks.com/help/vision/release-notes.html#R2011b
I suspect you have an older version of MATLAB than R2011b and so if you want to make it easy on yourself, you need to upgrade your version of MATLAB. However, if I may make a suggestion, I suggest the mexopencv project by Kota Yamaguchi: http://kyamagu.github.io/mexopencv/
He wrote OpenCV wrappers that can directly interface with MATLAB and so you can actually call OpenCV's SURF feature detection and matching methods from MATLAB but you will need to install OpenCV to do that. It will be a bit of work to get it working, but this is one solution I can provide if you don't want to upgrade your version of MATLAB.
Good luck!
I was learning how to do machine learning on mldata.org and I was watching a video on Youtube on how to use the data (https://www.youtube.com/watch?v=zY0UhXPy8fM) (2:50). Using the same data, I tried to follow exactly what he did and create a scatterplot of the dataset. However when he used the scatterplot command, it worked perfectly on his side, but I cannot do it on myside.
Can anyone explain what's wrong and what I should do?
octave:2> load banana_data.octave
octave:3> pkg load communications
octave:4> whos
Variables in the current scope:
Attr Name Size Bytes Class
==== ==== ==== ===== =====
data 2x5300 84800 double
label 1x5300 42400 double
Total is 15900 elements using 127200 bytes
octave:5> scatterplot(data, label)
error: scatterplot: real X must be a vector or a 2-column matrix
error: called from:
error: /home/anthony/octave/communications-1.2.0/scatterplot.m at line 69, column 7
The error message says it all. Your data is a 2-row matrix, and not a 2-column matrix as it should be. Just transpose it with .'.
scatterplot(data.')
I dropped the label argument since it is not compatible with the communications toolbox, either in matlab or in octave.
Update:
According to news('communications'),
The plotting functions eyediagram' andscatterplot' have improved Matlab compatibility
This may be why the behaviour is different. Be ready to find other glitches, as the octave 3.2.4 used in this course is about 5 years old.
In order to use the label, you should rather use the standard octave scatter function.
Colors could be changed by choosing another colormap.
colormap(cool(256))
scatter(data(1,:), data(2,:), 6, label, "filled")
Background: To support my study of Galois Theory I want to calculate Galois Groups from polynomials. This functionality is not readily available in Mma so I inquired and was advised to use the galois package in Mma ( or otherwise Sage / Pari ). The galois package can be downloaded from this location. http://library.wolfram.com/infocenter/Articles/2872/ ( The Galois package was written in the Mma 3 era. )
When loading the package galois.m, Mma displayed the following messages:
<<galois.m
SetDelayed::write: Tag Arrow in Arrow[Color_,{{x1_,y1_},{x2_,y2_}}] is Protected. >>
SetDelayed::write: Tag Norm in Norm[Poly_,a_Symbol] is Protected. >>
SetDelayed::write: Tag Norm in Norm[Poly_,{a__Symbol}] is Protected. >>
General::stop: Further output of SetDelayed::write will be suppressed during this calculation. >>
Question: Is a simple Unprotect of Arrow ( and so on ) sufficient to handle this issue? ( I have not tried yet. I want to await expert advice first before modifying any standard package ).
EDIT:
There are still problems after refactoring to Arrow1 ( or ArrowFnc ). This has been tested on
CircleGraph[{a, b, c, d, -a, -b, -c, -d}, F];
( from the example in the accompanying notebook. )
does not produce a graph.
CircleGraph[{a, b, c, d, -a, -b, -c, -d}, F]
( without ; ) produces a graph with additional text like FontForm[Symbol,18]. The arrows should contain only the text of the variables a,b,c and so on.
Further investigation shows that FontForm is terminally deprecated, this was not detected by Mma. See http://reference.wolfram.com/mathematica/ref/FontForm.html
You just need to replace occurrences of Arrow with something like ArrowFcn, and occurrences of Norm with something like NormFcn.
Arrow and Norm must have been added to the built-in functions after the galois package was written, so alternative names need to be used in the package.