## shinyTex: A LaTeX oriented authoring system for Shiny

#### Overview

ShinyTex is a system for authoring interactive World Wide Web applications (apps) which includes the full capabilities of the R statistical language, particularly in the context of Technology Enhanced Learning (TEL). It uses a modified version of the LaTeX syntax that is standard for document creation among mathematicians and statisticians. It is built on the Shiny platform, an extension of R designed by RStudio to produce web apps. The goal is to provide an easy to use TEL authoring environment with excellent mathematical and statistical support using only free software. ShinyTex authoring can be performed on Windows, OS X, and Linux. Users may view the app on any system with a standard web browser.

Manual

#### The R Package

Current version is 0.0-15.

#### Setup

As explained in the manual, for authoring and working on your own computer, you can setup your working directory using the shinyTex function setupShinyTex() once per directory.

For deployment on a Shiny server, the shinyTex R package is not required. The requirements for running apps created by shinyTex in Shiny are to place shinyTexAux.R in the working directory and shinyTex.css in a "www" subdirectory. (If you created your app with an old version of shinyTex, you may need the corresponding versions of these files, which are located in the "special" folder of the shinyTex installation folder on your computer.)

#### Sample apps

Template: shinyTexTemplate.tex

#### Acknowledgments

Thanks to Annie Zhang for testing and many helpful comments and corrections.

#### Change log

• Version 0.0-1 (July 18, 2015)
• Version 0.0-2 (August 6, 2015)
1. Added \shinyInternalLoc{name=myName} and \shinyInternalLink{name=myName; text=myText} to allow internal links (but this only works within a tab, not between tabs). [processCommands.R, innerCode.R]
2. Added \shinyGotoTab{name=my Tab Name; text=my Button Text} to create a button to jump to the top of another tab. [startDoList.R, cleanFiles.R, processCommands.R, innerCode.R]
• Version 0.0-3 (August 7, 2015)
1. valueId is unique across the authoring code
2. \shinyGotoTab is only used in a tabbed page and that it names a valid tab
3. \shinyConditionalPanel references a valid control, and if the control is a dropdown box, the value is one of the dropdown choices
4. any \shinyInternalLink controls have corresponding valid \shinyInternalLoc controls
5. \shinyGotoTab controls work even if multiple buttons are made to link to a single tab
[Created helpers.R, finalChecks.R, addTabObservers.R. Modified processTexRange.R, prefaceCode.R, processCommands.R, shinyTex.R, startDoList.R, makeCall.R, innerCode.R, downOne.R.]
• Version 0.0-4 (August 13, 2015)
1. Added warning code for malformed options
2. Fixed incorrect error text in compileQuizBank()
3. Pulled dropExtraCommas() into dropExtraCommas.R. Pulled writeUi() and writeServer() into write.R.
[Created dropExtraCommas.R, write.R Modified compileQuizBank.R, parseCommand.R, suffixCode.R, parseOptions.R, innerCode.R, finalCheck.R, shinyTex.R]
• Version 0.0-5 (August 17, 2015)
1. Added support for MathJax formulas to quiz banks
2. Added line numbers to error messages in compileQuizBank()
3. Added check for image and video to finalChecks()
[Created doMathJax.R Modified compileQuizBank.R, parseCommands.R, finalChecks.R]
• Version 0.0-6 (August 18, 2015)
1. Added support 'shinythemes' to change the overall look. Implemented with \def\theme{myChosenTheme}.
[Modified parseTex.R, startDoList.R]
• Version 0.0-7 (August 19, 2015)
1. Added support for an app background color via \defs\appBackgroundColor{myCSScolor}.
2. Added support in \shinyActionButton\shinyGotoTab for options textColor=, backgroundColor=, borderColor=, and style=. The first three use standard CSS color names. The last one allows multiple style elements of any type to be set at once, but because shinyTex uses a semicolon to separate options, the style elements must be separated by a vertical bar (|).
[Created makeStyle.R Modified parseTex.R, startDoList.R, processCommands.R, makeCall.R]
• Version 0.0-8 (August 29, 2015)
1. Allow \% to represent % (instead of comments) in quiz text.
2. Allow quiz questions to include line breaks and interpret multiple blanks as a paragraph break.
3. Prevent empty quiz questions from causing a syntax error.
[Modified compileQuizBank.R, doMathJax.R, shinyTexAux.R]
• Version 0.0-9 (May 9, 2016)
1. Added \shinyTextAreaInput allow multi-line input boxes.
2. Added runR() plus helper function removeComments() to process R code, e.g., from input boxes.
3. Added \shinyAudioInput to allow audio clips.
[Modified shinyTexAux.R, innerCode.R, processCommands.R, setupShinyTex.R; added textArea.js]
• Version 0.0-10 (May 24, 2016)
1. Added shinyRFeedback environment to define a user R input box and a feedback box.
2. Changed shinyTex() to run the most recently edited shinyTex file in the current directory if no argument is given (via guessFilename()).
[Modified innerCode.R, processCommands.R, setupShinyTex.R, parseOptions.R, processTex.R, shinyAux.R, shinyTex.r, guessFilename.R; added rFeedback.R]
• Version 0.0-11 (June 9, 2016)
1. Did major overhaul (not backward compatible) of shinyRFeedback environment plus addition of shinyRHiddenFeedback. Implemented SECTION*() to suppress regular expression matching compared to SECTION(). Implemented CALC: sections. Implemented optional use of conditions for [[NO]ERROR]GROUP:. And optional allowance to drop "DEFAULT:" if it is the only section in a group.
2. Changed shinyTex() and cleanFiles() to deal with RFeedbackFoo.R and RHiddenFeebackFoo.R files.
3. Added code to write AUTHORERRORLOG.txt and USERERRORLOG.txt as specified.
4. Added code to better report malformed beginEnvironmentFoo statements.
5. Added code to allow abbreviation of environment option names.
[Modified rFeedback.R, innerCode.R, parseCommand.R, shinyTex.R, cleanFiles.R, parseOptions.R, shinyAux.R, startDoList.R; added rHiddenFeedback.R, feedbackCommon.R, feedbackParser.R, makeCondition.R, getParen.R]
• Version 0.0-12 (June 21, 2016)
1. Added the shinyStoreCode environment to store reusable RFeedback code. The \shinyInsertCode{} command is used inside an RFeedback environment to insert the stored code.
2. Added the shinyRSesson environment to simulate an R session. R code is entered into the environment and a box is produced in the app showing what the R console would look like (including both input and output) if the code were entered there. Code lines entirely in parentheses are a "secret" syntax to cause the code to run without being displayed to the user.
3. Fixed multiple small errors.
4. Changed the default on \href{}{} (and its synonym, \shinyLink{}{}) to opening the link in the current window. Added \shinyLinkNew{}{} which opens the link in a new window.
5. Added \shinyMailto{link text}{email address}{subject line} to create a "mailto:" link.
6. Added support to allow a CALC block before the first GROUP block.
7. Added support to allow backtick notation to refer to user created variables in CALC blocks and CONDITION() statements. Specifically, x is converted to VARS[["x"]].
8. Made in shinyRFeedback environments, now allowSemicolons=FALSE only applies when nrows=1.
[Modified rFeedback.R, innerCode.R, parseCommand.R, rHiddenFeedback.R, feedbackCommon.R, feedbackParser.R, prefaceCode.R, processTex.R, makeCondition.R, and processCommands.R]
• Version 0.0-13 (July 7, 2016)
1. Added code to allow "checks" of rFeedback and hiddenRFeedback. For an RFeedback with id "Foo", create a file called "FooCheck.txt" containing sample user input for the feedback with alternate versions of user input separated by a line starting with at least 3 dashes. Then, when shinyTex() runs, the feedback for each alternate version will be placed in "FooCheckOut.txt". This output file starts with the name of the RFeedback, then the code being checked, then "---", then the feedback text. A long line of dashes separates different versions of the input. If a hiddenRFeedback is also present in the authoring file then its output is also show, preceeded by "(((((" and followed by ")))))". Finally, if a file called "FooCheckOK.txt" is present, a warning is produced if the current output does not match the output stored in "FooCheckOK.txt".
2. A new argument, checkDir= was added to shinyTex(). If this argument is specified, it is a directory containing check files (input, output, and OK files). The checks of the files in this "check directory" are made only if the checkDir= argument is used. In contrast, check file input in the current directory is always checked. This means that you can keep check input files in the current directory for RFeedback section you are currently improving, and not bother to check other sections. But when you want to verify the entire app, just add the checkDir= argument to check all inputs.
3. Fixed shinyInternalLink and shinyInternalLoc to work in-line.
4. Added global "defs" for font, color and background color for shinyInternalLink. This is useful for constructing in-tab menus.
5. Added \code{foo} for a particular font to set off computer code.
6. Added global "defs" for font, color and background color for \code{foo}.
7. Added \spaces{#} for nonbreaking horizonal spaces.
[Modified shinyTex.R, rFeedback.R, finalChecks.R, startDoList.R, processText.R, parseTex.R, htmlify.R, processCommands.R, innerCode.R, and parseCommand.R. Added runR.R (as a separate shinyTex file, in addition to the version in shinyTexAux.R.]
• Version 0.0-14 (July 23, 2016)
1. Added simple (exported) addSidebar(dropLink, dir) function to allow code from an simple singlePage app based on an enumerate or an itemize and containing links to a set of pages to the current app to be added as a sidebar. The sidebar reference to the current page should not be an active link, so if the text in 'dropLink' is found in the sidebar, it is coverted to its plain text.
2. Since "$" is used (in pairs) to indicate code to be converted to Tex equations, now "\$" can be used to produce a plain dollar sign.
3. Since in shinyRSession code like "x" does not print x, but it would in an R session, you can now use "print: x" to simulate the correct behavior. (But if "print:" is used with code that does print a result, the app will show duplcate output.)
4. Fixed shinyRSesson to treat comments as the would in a terminal session, i.e., the appear the have been typed at the command prompt.