📄 texi2dvi
字号:
#! /bin/sh# texi2dvi --- produce DVI (or PDF) files from Texinfo (or LaTeX) sources.# $Id: texi2dvi,v 1.14 2003/02/05 00:42:33 karl Exp $## Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001,# 2002, 2003 Free Software Foundation, Inc.## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2, or (at your option)# any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, you can either send email to this# program's maintainer or write to: The Free Software Foundation,# Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.## Original author: Noah Friedman <friedman@gnu.org>.## Please send bug reports, etc. to bug-texinfo@gnu.org.# If possible, please send a copy of the output of the script called with# the `--debug' option when making a bug report.# This string is expanded by rcs automatically when this file is checked out.rcs_revision='$Revision: 1.14 $'rcs_version=`set - $rcs_revision; echo $2`program=`echo $0 | sed -e 's!.*/!!'`version="texi2dvi (GNU Texinfo 4.5) $rcs_versionCopyright (C) 2003 Free Software Foundation, Inc.There is NO warranty. You may redistribute this softwareunder the terms of the GNU General Public License.For more information about these matters, see the files named COPYING."usage="Usage: $program [OPTION]... FILE...Run each Texinfo or LaTeX FILE through TeX in turn until allcross-references are resolved, building all indices. The directorycontaining each FILE is searched for included files. The suffix of FILEis used to determine its language (LaTeX or Texinfo).Makeinfo is used to perform Texinfo macro expansion before running TeXwhen needed.Operation modes: -b, --batch no interaction -c, --clean remove all auxiliary files -D, --debug turn on shell debugging (set -x) -h, --help display this help and exit successfully -o, --output=OFILE leave output in OFILE (implies --clean); Only one input FILE may be specified in this case -q, --quiet no output unless errors (implies --batch) -s, --silent same as --quiet -v, --version display version information and exit successfully -V, --verbose report on what is doneTeX tuning: -@ use @input instead of \input; for preloaded Texinfo -e, -E, --expand force macro expansion using makeinfo -I DIR search DIR for Texinfo files -l, --language=LANG specify the LANG of FILE (LaTeX or Texinfo) -p, --pdf use pdftex or pdflatex for processing -t, --texinfo=CMD insert CMD after @setfilename in copy of input file multiple values accumulateThe values of the BIBTEX, LATEX (or PDFLATEX), MAKEINDEX, MAKEINFO,TEX (or PDFTEX), and TEXINDEX environment variables are used to runthose commands, if they are set.Email bug reports to <bug-texinfo@gnu.org>,general questions and discussion to <help-texinfo@gnu.org>.Texinfo home page: http://www.gnu.org/software/texinfo/"# Initialize variables for option overriding and otherwise.# Don't use `unset' since old bourne shells don't have this command.# Instead, assign them an empty value.batch=false # eval for batch modeclean=debug=escape='\'expand= # t for expansion via makeinfomiincludes= # makeinfo include pathoformat=dvioname= # --outputquiet= # by default let the tools' message be displayedset_language=textra=tmpdir=${TMPDIR:-/tmp}/t2d$$ # avoid collisions on 8.3 filesystems.txincludes= # TEXINPUTS extensions, with trailing colontxiprereq=19990129 # minimum texinfo.tex version to have macro expansionverbose=false # echo for verbose modeorig_pwd=`pwd`# Systems which define $COMSPEC or $ComSpec use semicolons to separate# directories in TEXINPUTS.if test -n "$COMSPEC$ComSpec"; then path_sep=";"else path_sep=":"fi# Pacify verbose cds.CDPATH=${ZSH_VERSION+.}$path_sep# In case someone crazy insists on using grep -E.: ${EGREP=egrep}# Save this so we can construct a new TEXINPUTS path for each file.TEXINPUTS_orig="$TEXINPUTS"# Unfortunately makeindex does not read TEXINPUTS.INDEXSTYLE_orig="$INDEXSTYLE"export TEXINPUTS INDEXSTYLE# Push a token among the arguments that will be used to notice when we# ended options/arguments parsing.# Use "set dummy ...; shift" rather than 'set - ..." because on# Solaris set - turns off set -x (but keeps set -e).# Use ${1+"$@"} rather than "$@" because Digital Unix and Ultrix 4.3# still expand "$@" to a single argument (the empty string) rather# than nothing at all.arg_sep="$$--$$"set dummy ${1+"$@"} "$arg_sep"; shift# # Parse command line arguments.while test x"$1" != x"$arg_sep"; do # Handle --option=value by splitting apart and putting back on argv. case "$1" in --*=*) opt=`echo "$1" | sed -e 's/=.*//'` val=`echo "$1" | sed -e 's/[^=]*=//'` shift set dummy "$opt" "$val" ${1+"$@"}; shift ;; esac # This recognizes --quark as --quiet. So what. case "$1" in -@ ) escape=@;; # Silently and without documentation accept -b and --b[atch] as synonyms. -b | --b*) batch=eval;; -q | -s | --q* | --s*) quiet=t; batch=eval;; -c | --c*) clean=t;; -D | --d*) debug=t;; -e | -E | --e*) expand=t;; -h | --h*) echo "$usage"; exit 0;; -I | --I*) shift miincludes="$miincludes -I $1" txincludes="$txincludes$1$path_sep" ;; -l | --l*) shift; set_language=$1;; -o | --o*) shift clean=t case "$1" in /* | ?:/*) oname=$1;; *) oname="$orig_pwd/$1";; esac;; -p | --p*) oformat=pdf;; -t | --t*) shift; textra="$textra\\$1";; -v | --vers*) echo "$version"; exit 0;; -V | --verb*) verbose=echo;; --) # What remains are not options. shift while test x"$1" != x"$arg_sep"; do set dummy ${1+"$@"} "$1"; shift shift done break;; -*) echo "$0: Unknown or ambiguous option \`$1'." >&2 echo "$0: Try \`--help' for more information." >&2 exit 1;; *) set dummy ${1+"$@"} "$1"; shift;; esac shiftdone# Pop the tokenshift# Interpret remaining command line args as filenames.case $# in 0) echo "$0: Missing file arguments." >&2 echo "$0: Try \`--help' for more information." >&2 exit 2 ;; 1) ;; *) if test -n "$oname"; then echo "$0: Can't use option \`--output' with more than one argument." >&2 exit 2 fi ;;esac# Prepare the temporary directory. Remove it at exit, unless debugging.if test -z "$debug"; then trap "cd / && rm -rf $tmpdir" 0 1 2 15fi# Create the temporary directory with strict rights(umask 077 && mkdir $tmpdir) || exit 1# Prepare the tools we might need. This may be extra work in some# cases, but improves the readibility of the script.utildir=$tmpdir/utilsmkdir $utildir || exit 1# A sed script that preprocesses Texinfo sources in order to keep the# iftex sections only. We want to remove non TeX sections, and# comment (with `@c texi2dvi') TeX sections so that makeinfo does not# try to parse them. Nevertheless, while commenting TeX sections,# don't comment @macro/@end macro so that makeinfo does propagate# them. Unfortunately makeinfo --iftex --no-ifhtml --no-ifinfo# doesn't work well enough (yet) to use that, so work around with sed.comment_iftex_sed=$utildir/comment.sedcat <<EOF >$comment_iftex_sed/^@tex/,/^@end tex/{ s/^/@c texi2dvi/}/^@iftex/,/^@end iftex/{ s/^/@c texi2dvi/ /^@c texi2dvi@macro/,/^@c texi2dvi@end macro/{ s/^@c texi2dvi// }}/^@html/,/^@end html/{ s/^/@c (texi2dvi)/}/^@ifhtml/,/^@end ifhtml/{ s/^/@c (texi2dvi)/}/^@ifnottex/,/^@end ifnottex/{ s/^/@c (texi2dvi)/}/^@ifinfo/,/^@end ifinfo/{ /^@node/p /^@menu/,/^@end menu/p t s/^/@c (texi2dvi)/}s/^@ifnotinfo/@c texi2dvi@ifnotinfo/s/^@end ifnotinfo/@c texi2dvi@end ifnotinfo/EOF# Uncommenting is simple: Remove any leading `@c texi2dvi'.uncomment_iftex_sed=$utildir/uncomment.sedcat <<EOF >$uncomment_iftex_seds/^@c texi2dvi//EOF# A shell script that computes the list of xref files.# Takes the filename (without extension) of which we look for xref# files as argument. The index files must be reported last.get_xref_files=$utildir/get_xref.shcat <<\EOF >$get_xref_files#! /bin/sh# Get list of xref files (indexes, tables and lists).# Find all files having root filename with a two-letter extension,# saves the ones that are really Texinfo-related files. .?o? catches# many files: .toc, .log, LaTeX tables and lists, FiXme's .lox, maybe more.for this_file in "$1".?o? "$1".aux "$1".?? "$1".idx; do # If file is empty, skip it. test -s "$this_file" || continue # If the file is not suitable to be an index or xref file, don't # process it. The file can't be if its first character is not a # backslash or single quote. first_character=`sed -n '1s/^\(.\).*$/\1/p;q' $this_file` if test "x$first_character" = "x\\" \ || test "x$first_character" = "x'"; then xref_files="$xref_files ./$this_file" fidoneecho "$xref_files"EOFchmod 500 $get_xref_files# File descriptor usage:# 0 standard input# 1 standard output (--verbose messages)# 2 standard error# 3 some systems may open it to /dev/tty# 4 used on the Kubota Titan# 5 tools output (turned off by --quiet)# Tools' output. If quiet, discard, else redirect to the message flow.if test "$quiet" = t; then exec 5>/dev/nullelse exec 5>&1fi# Enable tracingtest "$debug" = t && set -x# # TeXify files.for command_line_filename in ${1+"$@"}; do $verbose "Processing $command_line_filename ..." # If the COMMAND_LINE_FILENAME is not absolute (e.g., --debug.tex), # prepend `./' in order to avoid that the tools take it as an option. echo "$command_line_filename" | $EGREP '^(/|[A-z]:/)' >/dev/null \ || command_line_filename="./$command_line_filename" # See if the file exists. If it doesn't we're in trouble since, even # though the user may be able to reenter a valid filename at the tex # prompt (assuming they're attending the terminal), this script won't # be able to find the right xref files and so forth. if test ! -r "$command_line_filename"; then echo "$0: Could not read $command_line_filename, skipping." >&2 continue fi # Get the name of the current directory. We want the full path # because in clean mode we are in tmp, in which case a relative # path has no meaning. filename_dir=`echo $command_line_filename | sed 's!/[^/]*$!!;s!^$!.!'` filename_dir=`cd "$filename_dir" >/dev/null && pwd`
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -