如何在 LaTeX Lab 中为我的 LaTeX 文档使用自定义编译器?

发布于 2024-08-31 23:18:54 字数 6494 浏览 3 评论 0原文

我正在使用 LaTeX,最近发布了 LaTeX Lab,这是一个 Google 文档的在线 LaTeX 界面。

在大多数情况下,这个在线 LaTeX 编译器非常棒,我可以得到这样的文档进行编译:

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\title{\LaTeX without extra usepackages}
\date{}
\begin{document}
  \maketitle
  I would like to know how to use \LaTeX{} with extra packages.

  % This is a comment; it is not shown in the final output.
  % The following shows a little of the typesetting power of LaTeX
  \begin{align}
    E &= mc^2                              \\
    m &= \frac{m_0}{\sqrt{1-\frac{v^2}{c^2}}}
  \end{align}
\end{document}

但是,使用更多包的较大文档无法编译,即使它们在本地安装的 LaTeX 上也可以编译。一个例子如下:

% 
% This document illustrates using LaTeX. LaTeX2HTML and DVIPDFM together
% for graphics and hyperlinks.
% 
%
\documentclass[12pt,a4paper,dvipdfm]{article}
\usepackage[dvips]{graphicx}
\usepackage[usenames,dvipsnames]{color} 
\usepackage{html}
%
% The lines below to use HYPERREF need to be commented out to get numbering to work 
% in the HTML version. Once commented out, run LaTeX several times, and then LaTeX2HTML:
%
%\usepackage[dvipdfm, latex2html,
%                           colorlinks, linkcolor=blue, urlcolor=blue, citecolor=blue,
%                           bookmarks, bookmarksopen, bookmarksnumbered,
%                           pdfauthor={Charles Clayton}]{hyperref}
%
% The command below simplifies the process of including an image. It assumes that the images
% are in a sub-folder called "graphics" in the folder that the .tex document lives in.
% It also assumes a bounding box file created e.g. with EBB exists in the subdirectory.
% If the graphic is (for example) called graph.jpg, then the bounding box file should be graph.bb
% The first parameter is the name of the image, the second the text for the ALT tag.
% Note that for some reason it goes wrong if you use \begin{htmlonly}...\end{htmlonly}
% instead of \html. This "feature" might however change in subsequent versions.
%
\newcommand{\img}[2]{
\begin{makeimage}
\end{makeimage}
\centering
\latex{\includegraphics{graphics/#1}}
\html{\htmladdimg[ALT="#2"]{../graphics/#1}}}
%
% The next two commands are just modified versions of \img
% The first shows how to put a box round things in both the HTML and PDF versions
% The seconds shows how to scale the image.
%
\newcommand{\boxedimg}[2]{
\begin{makeimage}
\end{makeimage}
\centering
\latex{\fbox{\includegraphics{graphics/#1}}}
\html{\htmladdimg[ALT="#2" BORDER="1"]{../graphics/#1}}}
%
\newcommand{\scaledimg}[2]{
\begin{makeimage}
\end{makeimage}
\centering
\latex{\includegraphics[scale=0.5]{graphics/#1}}
\html{\htmladdimg[ALT="#2" WIDTH="5cm"]{../graphics/#1}}}
%
%
%
\title{Example Document}
\author{Charles Clayton}

\begin{document}
\maketitle

\abstract{
This document includes graphics and hyperlinks and should run correctly through 
both LaTeX2HTML and DVIPDFM. See the document 
\htmladdnormallink{Getting \LaTeX\ and \LaTeX2HTML\ and DVIPDFM to Work Together}
{http://members.tripod.com/charlesclayton/index.htm} for more information.}

\tableofcontents\section{Hyperlinks}

These links should `work' (i.e. be clickable) in both the PDF and HTML documents.
\begin{itemize}
\item A link to an external web page: \htmladdnormallink{Amazon.com}{http://www.amazon.com}
\item A link to the \htmlref{next section}{sec:Gr}
\item A link to the next section, using a standard \verb+\ref+: Section \ref{sec:Gr}. 
To get section numbers you must use the \verb+show_section_numbers+ command line 
option with \LaTeX2HTML. Also, the line that uses the \verb+hyperref+ package must 
be commented out (due to a bug) and LaTeX re-run several times before running \LaTeX2HTML.
\item It does not seem possible to get a single link to e.g. `Section 2', as 
\verb+\ref+ does not work within \verb+\htmlref+ and similar commands. 
One can get nearly there by combining an \verb+\htmlref+ 
and a \verb+\ref+: \htmlref{Section}{sec:Gr} \ref{sec:Gr}.
\item This is an ordinary \verb+\cite+: \cite{ref1}. Note that \verb+\htmlcite+ does not
 seem to work in the PDF version (unlike \verb+\htmlref+ which works in both)
\item This is a reference to equation \ref{eqn1}
\item This is a reference to the \htmlref{same equation}{eqn1} done with \verb+\htmlref+
\end{itemize}

\section{Graphics}
\label{sec:Gr}
The figures in this document demonstrate including a JPEG image in both the PDF and HTML
versions. For details of how to use EPS graphics, see the document
\htmladdnormallink{Getting \LaTeX\ and \LaTeX2HTML\ and DVIPDFM to Work Together}
{http://members.tripod.com/charlesclayton/index.htm}. Notice that
\begin{itemize}
\item the ALT tag is set in the HTML versions;
\item if the \verb+\caption+ comes before the \verb+\includegraphics+, 
the caption will be above the image, otherwise it will be below the image. 
This is only the case in the PDF document, however.
\end{itemize}

\begin{figure}
\img{graphic.jpg}{A graph of some statistical distributions}
\caption{A graphic}
\end{figure}

\begin{figure}
\boxedimg{graphic.jpg}{A boxed graph}
\caption{A boxed graphic}
\end{figure}

\begin{figure}
\caption{A scaled graphic. In the PDF version, the caption will be on top of the image}
\scaledimg{graphic.jpg}{A scaled graph}
\end{figure}

\section{Other Remarks}
\begin{itemize}
\item Note that the PDF version has working bookmarks;
\item The author field is also set in the PDF document information;
\item Note the use of a ALT tag in the equation below. 
This provides meaningful alternative text if the equation is not displayed or a tool tip
\end{itemize}
\begin{equation}
\htmlimage{ALT="A fundamental equation"}
\label{eqn1}
e^{i\pi}=-1
\end{equation}


\begin{thebibliography}{99}
\bibitem{ref1} A test bibliography entry.
\end{thebibliography}

\end{document}

我想使用 LaTeX Labs 在线访问、编辑和编译 Latex 文档。使用我自己的服务器上的私有编译器可以解决此问题吗?有更简单的方法吗?如果没有,任何人都可以指出我正确的方向来设置它吗? 此教程的主页面是空白的。 (更新:现在那里有一些描述。)

还有其他教程页面:

I'm using LaTeX, and recently LaTeX Lab, an online LaTeX interface to Google docs, was released.

For the most part this online LaTeX compiler is great, and I can get a document such as this to compile:

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\title{\LaTeX without extra usepackages}
\date{}
\begin{document}
  \maketitle
  I would like to know how to use \LaTeX{} with extra packages.

  % This is a comment; it is not shown in the final output.
  % The following shows a little of the typesetting power of LaTeX
  \begin{align}
    E &= mc^2                              \\
    m &= \frac{m_0}{\sqrt{1-\frac{v^2}{c^2}}}
  \end{align}
\end{document}

However, larger documents using more packages don't compile, even though they do on local installations of LaTeX. An example is below:

% 
% This document illustrates using LaTeX. LaTeX2HTML and DVIPDFM together
% for graphics and hyperlinks.
% 
%
\documentclass[12pt,a4paper,dvipdfm]{article}
\usepackage[dvips]{graphicx}
\usepackage[usenames,dvipsnames]{color} 
\usepackage{html}
%
% The lines below to use HYPERREF need to be commented out to get numbering to work 
% in the HTML version. Once commented out, run LaTeX several times, and then LaTeX2HTML:
%
%\usepackage[dvipdfm, latex2html,
%                           colorlinks, linkcolor=blue, urlcolor=blue, citecolor=blue,
%                           bookmarks, bookmarksopen, bookmarksnumbered,
%                           pdfauthor={Charles Clayton}]{hyperref}
%
% The command below simplifies the process of including an image. It assumes that the images
% are in a sub-folder called "graphics" in the folder that the .tex document lives in.
% It also assumes a bounding box file created e.g. with EBB exists in the subdirectory.
% If the graphic is (for example) called graph.jpg, then the bounding box file should be graph.bb
% The first parameter is the name of the image, the second the text for the ALT tag.
% Note that for some reason it goes wrong if you use \begin{htmlonly}...\end{htmlonly}
% instead of \html. This "feature" might however change in subsequent versions.
%
\newcommand{\img}[2]{
\begin{makeimage}
\end{makeimage}
\centering
\latex{\includegraphics{graphics/#1}}
\html{\htmladdimg[ALT="#2"]{../graphics/#1}}}
%
% The next two commands are just modified versions of \img
% The first shows how to put a box round things in both the HTML and PDF versions
% The seconds shows how to scale the image.
%
\newcommand{\boxedimg}[2]{
\begin{makeimage}
\end{makeimage}
\centering
\latex{\fbox{\includegraphics{graphics/#1}}}
\html{\htmladdimg[ALT="#2" BORDER="1"]{../graphics/#1}}}
%
\newcommand{\scaledimg}[2]{
\begin{makeimage}
\end{makeimage}
\centering
\latex{\includegraphics[scale=0.5]{graphics/#1}}
\html{\htmladdimg[ALT="#2" WIDTH="5cm"]{../graphics/#1}}}
%
%
%
\title{Example Document}
\author{Charles Clayton}

\begin{document}
\maketitle

\abstract{
This document includes graphics and hyperlinks and should run correctly through 
both LaTeX2HTML and DVIPDFM. See the document 
\htmladdnormallink{Getting \LaTeX\ and \LaTeX2HTML\ and DVIPDFM to Work Together}
{http://members.tripod.com/charlesclayton/index.htm} for more information.}

\tableofcontents\section{Hyperlinks}

These links should `work' (i.e. be clickable) in both the PDF and HTML documents.
\begin{itemize}
\item A link to an external web page: \htmladdnormallink{Amazon.com}{http://www.amazon.com}
\item A link to the \htmlref{next section}{sec:Gr}
\item A link to the next section, using a standard \verb+\ref+: Section \ref{sec:Gr}. 
To get section numbers you must use the \verb+show_section_numbers+ command line 
option with \LaTeX2HTML. Also, the line that uses the \verb+hyperref+ package must 
be commented out (due to a bug) and LaTeX re-run several times before running \LaTeX2HTML.
\item It does not seem possible to get a single link to e.g. `Section 2', as 
\verb+\ref+ does not work within \verb+\htmlref+ and similar commands. 
One can get nearly there by combining an \verb+\htmlref+ 
and a \verb+\ref+: \htmlref{Section}{sec:Gr} \ref{sec:Gr}.
\item This is an ordinary \verb+\cite+: \cite{ref1}. Note that \verb+\htmlcite+ does not
 seem to work in the PDF version (unlike \verb+\htmlref+ which works in both)
\item This is a reference to equation \ref{eqn1}
\item This is a reference to the \htmlref{same equation}{eqn1} done with \verb+\htmlref+
\end{itemize}

\section{Graphics}
\label{sec:Gr}
The figures in this document demonstrate including a JPEG image in both the PDF and HTML
versions. For details of how to use EPS graphics, see the document
\htmladdnormallink{Getting \LaTeX\ and \LaTeX2HTML\ and DVIPDFM to Work Together}
{http://members.tripod.com/charlesclayton/index.htm}. Notice that
\begin{itemize}
\item the ALT tag is set in the HTML versions;
\item if the \verb+\caption+ comes before the \verb+\includegraphics+, 
the caption will be above the image, otherwise it will be below the image. 
This is only the case in the PDF document, however.
\end{itemize}

\begin{figure}
\img{graphic.jpg}{A graph of some statistical distributions}
\caption{A graphic}
\end{figure}

\begin{figure}
\boxedimg{graphic.jpg}{A boxed graph}
\caption{A boxed graphic}
\end{figure}

\begin{figure}
\caption{A scaled graphic. In the PDF version, the caption will be on top of the image}
\scaledimg{graphic.jpg}{A scaled graph}
\end{figure}

\section{Other Remarks}
\begin{itemize}
\item Note that the PDF version has working bookmarks;
\item The author field is also set in the PDF document information;
\item Note the use of a ALT tag in the equation below. 
This provides meaningful alternative text if the equation is not displayed or a tool tip
\end{itemize}
\begin{equation}
\htmlimage{ALT="A fundamental equation"}
\label{eqn1}
e^{i\pi}=-1
\end{equation}


\begin{thebibliography}{99}
\bibitem{ref1} A test bibliography entry.
\end{thebibliography}

\end{document}

I would like to use LaTeX Labs to access, edit, and compile latex documents online. Is using a private compiler off of my own server a solution to this problem? Is there an easier way? If not, can anyone point me in the correct direction to set this up? The main tutorial page for this is blank. (Update: Now there is some description there.)

There are other tutorial pages as well:

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

呆° 2024-09-07 23:18:54

如果您有兴趣包含一些额外的包,您可以将它们作为样式文档上传,而不是使用 CLSI

文件 ->上传文件

然后您可以将它们包含在您的编译中

编译器->项目资源

例如我上传了以下两个文件:

http://www.math.toronto.edu/~drorbn /VasBib/html.sty

http://lx2.saas.hku.hk /Conference/IascAsian05/hkustasc/template/graphicx.sty

并能够编译上述问题中的 Tex 文档。

Rather than use the CLSI, if you are interested in including a few extra packages you can upload them as style documents

Files -> Upload Files

Then you can include them in your compilation

Compiler -> Project resources

For example I uploaded the following two files:

http://www.math.toronto.edu/~drorbn/VasBib/html.sty

http://lx2.saas.hku.hk/Conference/IascAsian05/hkustasc/template/graphicx.sty

and was able to compile the Tex document in the question above.

我的痛♀有谁懂 2024-09-07 23:18:54

您可以在 CLSI 项目站点上找到一些有关启动 CLSI 服务器实例的文档:
http://code.google.com/p/common- Latex-service-interface/wiki/InstallAndConfig

有关在 LaTeX Lab 中使用自定义 CLSI 环境的说明,请参阅以下页面:
code.google.com/p/latex-lab/wiki/UsingPrivateCompiler

如果您打算向一组用户公开自定义的(也许更强大的)LaTeX 编译器,我只建议您启动 CLSI 实例。为了避免丢失包裹,我建议遵循 DW 的回复。

在不久的将来,您将可以选择使用本地 TeX Live/MikTeX 安装,这样您就可以使用自定义 LaTeX 环境,而无需启动 CLSI 服务器。

You can find some documentation on bringing up a CLSI server instance on the CLSI project site:
http://code.google.com/p/common-latex-service-interface/wiki/InstallAndConfig

For directions on using a custom CLSI environment with LaTeX Lab see the following page:
code.google.com/p/latex-lab/wiki/UsingPrivateCompiler

I would only recommend bringing up a CLSI instance if you're planning to expose a custom, perhaps more powerful, LaTeX compiler, to a set of users. For getting around missing packages i recommend following DW's response.

There will be an option in the near future to use a local TeX Live/MikTeX installation, this way you'll be able to use a custom LaTeX environment without bringing up a CLSI server.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文