I know that
\documentclass{article}
\usepackage{mathrsfs}
\usepackage{extarrows}
\begin{document}
$\mathscr{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$
\end{document}
produce :
but I want to know what is the necessary command to get :
scripts
I know that
\documentclass{article}
\usepackage{mathrsfs}
\usepackage{extarrows}
\begin{document}
$\mathscr{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$
\end{document}
produce :
but I want to know what is the necessary command to get :
\documentclass{article}
\begingroup\makeatletter\endlinechar=\m@ne\everyeof{\noexpand}
\edef\x{\endgroup\def\noexpand\TeXpath{\@@input|"which tex" }}\x
\begin{document}
File listing is
{\catcode`_=12 \ttfamily
\input{|"ls /usr" }
}
\TeX{} is \TeXpath
\end{document}
We must use \@@input
(the primitive \input
command) because \input
in LaTeX does assignments. The setting of \endlinechar
is to avoid a spurious space in the expansion of \TeXpath
.
When shell escape is active and the primitive \input
finds a |
, it accepts as input the standard output of the following shell command.
There should be a package by H. Oberdiek that does something of this kind.
Note An assignment is any TeX operation that gives a meaning or a value to a control sequence or register. During the \edef
operation, TeX expands all commands it finds between the braces until only unexpandable tokens remain, but doesn't perform any assignment; rather, something like \catch=22
(where \catch
is the name of a count register) remains completely inaltered. Since the definition of \input
in LaTeX is
\@ifnextchar\bgroup\@iinput\@@input
the implicit assignments performed by \@ifnextchar
would not be performed and both \@input
and \@@input
would be expanded, which results in a complete disaster. Conversely, the \input
primitive (that LaTeX saves as \@@input
) is expandable and its expansion consists in causing TeX to read the named file. One has, of course, to be careful about what this file contains, as also this will be expanded. So other precautions have to be taken when doing this kind of operations, depending on the nature of the tokens produced by the command we want to perform and this "solution" is only a skeleton for possible "real" applications.
After some years, things have changed and better methods are available.
For instance, with xparse
and expl3
the code can be improved:
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\captureshell}{som}
{
\sdaau_captureshell:Ne \l__sdaau_captureshell_out_tl { #3 }
\IfBooleanT { #1 }
{% we may need to stringify the result
\tl_set:Nx \l__sdaau_captureshell_out_tl
{ \tl_to_str:N \l__sdaau_captureshell_out_tl }
}
\IfNoValueTF { #2 }
{
\tl_use:N \l__sdaau_captureshell_out_tl
}
{
\tl_set_eq:NN #2 \l__sdaau_captureshell_out_tl
}
}
\tl_new:N \l__sdaau_captureshell_out_tl
\cs_new_protected:Nn \sdaau_captureshell:Nn
{
\sys_get_shell:nnN { #2 } { } #1
\tl_trim_spaces:N #1 % remove leading and trailing spaces
}
\cs_generate_variant:Nn \sdaau_captureshell:Nn { Ne }
\ExplSyntaxOff
\begin{document}
\captureshell*[\TeXpath]{which tex} % we need to stringify it because of _
File listing is
{\ttfamily\captureshell{ls \jobname.*}\par}
\TeX{} is \texttt{\TeXpath}
\end{document}
We could add an error message if the user doesn't pass the -shell-escape
option for the LaTeX run.
Check also texosquery
(requires Java).
I will assume that by shell you mean a Unix shell such as bash
. You may want to look at the "here document" feature of bash. The simplest you can do is
#!/bin/bash
latex <<theend
\documentclass{article}
\begin{document}
Blah blah
\end{document}
theend
echo "Done!"
however this may lead to some problems if the latex processing needs multiple passes. It will also clutter your current directory with bunch of extra files produced by latex
, such as log file, .aux
file, etc., which may not be what you want.
A better option is to create a temporary directory, extract the LaTeX document into it using cat
and to run LaTeX with this document as input. You may want to run LaTeX several times to make sure all cross references are resolved. At the end you just copy the generated .dvi
or .pdf
file back to your current directory.
An example of such script is below. It uses mktemp
to create a temporary directory. As far as I know, mktemp
is not available on every Unix, but it should be available on every system that has GNU coreutils.
There are probably better ways how to handle pretty much every step of the process, but this should get you started.
#!/bin/bash
# Create a temporary directory
curdir=$( pwd )
tmpdir=$( mktemp -dt "latex.XXXXXXXX" )
# Set up a trap to clean up and return back when the script ends
# for some reason
clean_up () {
cd "$curdir"
[ -d "$tmpdir" ] && rm -rf "$tmpdir"
exit
}
trap 'clean_up' EXIT SIGHUP SIGINT SIGQUIT SIGTERM
# Switch to the temp. directory and extract the .tex file
cd $tmpdir
# Quoting the 'THEEND' string prevents $-expansion.
cat > myfile.tex <<'THEEND'
\documentclass{article}
\begin{document}
Blah blah \(x^2 + 1\) or $x^2 + 1$.
\end{document}
THEEND
# If the file extracts succesfully, try to run pdflatex 3 times.
# If something fails, print a warning and exit
if [[ -f 'myfile.tex' ]]
then
for i in {1..3}
do
if pdflatex myfile.tex
then
echo "Pdflatex run $i finished."
else
echo "Pdflatex run $i failed."
exit 2
fi
done
else
echo "Error extracting .tex file"
exit 1
fi
# Copy the resulting .pdf file to original directory and exit
cp myfile.pdf $curdir
exit 0
Best Answer
\mathscr
will give script fonts in math-mode only for upper cased letters; the shape will depend on the package used. As far as I know, there's no font providing this kind of fonts for lower-cased letters in math-mode. Don't use\mathscr
to write regular, non-math text (it's intended to be used in math expressions).In text mode, you can use the
calligra
font, provided by thecalligra
package:Another option would be to use XeLaTeX and a font like the one in the image.