Path: blob/master/src/packages/next/pages/features/latex-editor.tsx
5907 views
/*1* This file is part of CoCalc: Copyright © 2022 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { Descriptions, Layout, List } from "antd";67import { Icon } from "@cocalc/frontend/components/icon";8import { DARK_MODE_ICON } from "@cocalc/util/consts/ui";9import { COLORS } from "@cocalc/util/theme";1011import Backups from "components/landing/backups";12import Code from "components/landing/code";13import Collaboration from "components/landing/collaboration";14import Comparison from "components/landing/compare";15import Content from "components/landing/content";16import Footer from "components/landing/footer";17import Head from "components/landing/head";18import Header from "components/landing/header";19import Info from "components/landing/info";20import LaTeX from "components/landing/latex";21import Pitch from "components/landing/pitch";22import Publishing from "components/landing/publishing";23import SignIn from "components/landing/sign-in";24import { Paragraph, Text, Title } from "components/misc";25import A from "components/misc/A";2627import { Customize } from "lib/customize";28import withCustomize from "lib/with-customize";2930import Pythontex from "public/features/cocalc-pythontex.png";31import Sagetex from "public/features/cocalc-sagetex.png";32import AIFormula from "public/features/latex-ai-formula.png";33import CustomCommand from "public/features/latex-custom-command-02.png";34import LatexDarkMode from "public/features/latex-editor-darkmode-20251003.png";35import LatexEditorImage from "public/features/latex-editor-main-20251003.png";36import LatexPythontex from "public/features/latex-editor-pythontex-20251003.png";37import LatexCollab from "public/features/latex-editor-realtime-sync-20251003.png";38import LaTeXMultiFile from "public/features/latex-editor-multifile-20251006.png";39import Knitr from "public/features/latex-editor-rnw-01.png";40import Sidechat from "public/features/latex-editor-side-chat-20251004.png";41import LatexTimetravel from "public/features/latex-editor-timetravel-01.png";42import Logo from "public/features/latex-logo.svg";4344export default function LatexEditor({ customize }) {45return (46<Customize value={customize}>47<Head title="Online LaTeX Editor" />48<Layout>49<Header page="features" subPage="latex-editor" />50<Layout.Content>51<Content52landing53startup={<LaTeX />}54body={Logo}55title={"Online LaTeX Editor"}56subtitle={57<>58Focus on writing LaTeX. CoCalc takes care of everything else.59{/*<hr />60<A href="https://about.cocalc.com/2023/01/13/cocalcs-online-latex-editor/">61Learn much more about LaTeX in CoCalc from this new blog62post...63</A> */}64</>65}66image={LatexEditorImage}67/>6869<Pitch70col1={71<>72<Title73level={2}74style={{75minHeight: "60px",76display: "flex",77alignItems: "center",78flexWrap: "wrap",79}}80>81<span>82Working with <LaTeX /> made easy83</span>84</Title>85<Paragraph>86<List bordered size="small">87<List.Item>88<strong>Side-by-side preview</strong> with{" "}89<strong>90<a href="#a-forwardinverse">91forward and inverse search92</a>93</strong>{" "}94(TEX ↔ PDF)95</List.Item>96<List.Item>97<strong>Automatically compiles upon saving</strong> and98marks problems in the source file99</List.Item>100<List.Item>101<strong>102<a href="#a-timetravel">Records every change</a>103</strong>{" "}104while you type with{" "}105<strong>106<a href="#a-backups">periodic backups</a>107</strong>{" "}108of all files109</List.Item>110<List.Item>111<strong>112<a href="#a-ai-formula">AI-powered formula assistant</a>113</strong>{" "}114typesets formulas for you115</List.Item>116<List.Item>117<strong>118<a href="#a-calculations">Runs embedded calculations</a>119</strong>{" "}120with support for <a href="#a-sagetex">SageTeX</a>,{" "}121<a href="#a-pythontex">PythonTeX</a> and{" "}122<a href="#a-knitr">Knitr</a>123</List.Item>124<List.Item>125<strong>126<a href="#a-multifile">Multi-file support</a>127</strong>{" "}128that discovers included files automatically129</List.Item>130</List>131</Paragraph>132</>133}134col2={135<>136<Title137level={2}138style={{139minHeight: "60px",140display: "flex",141alignItems: "center",142flexWrap: "wrap",143}}144>145<span>Fully-featured online editor</span>146</Title>147<Paragraph>148<List bordered size="small">149<List.Item>150<strong>151<a href="#a-realtimesync">Real-time collaboration</a>152</strong>{" "}153with unlimited collaborators154</List.Item>155<List.Item>156<strong>157<a href="#a-chat">Side-by-side chat</a>158</strong>{" "}159to discuss documents with collaborators and AI160</List.Item>161<List.Item>162<strong>163<a href="#a-darkmode">Dark Mode with PDF support</a>164</strong>{" "}165for comfortable night-time editing166</List.Item>167<List.Item>168<strong>169<a href="#a-timetravel">Complete revision history</a>170</strong>{" "}171to revert any changes172</List.Item>173<List.Item>174<strong>175<a href="#a-environments">176Fully managed <LaTeX /> environment177</a>178</strong>{" "}179with PDF LaTeX, XeLaTeX, and LuaTeX180</List.Item>181<List.Item>182<strong>183<a href="#a-computational">184Full computational environment185</a>186</strong>{" "}187accessible from any browser188</List.Item>189</List>190</Paragraph>191</>192}193ext="tex"194/>195196<SignIn startup={<LaTeX />} />197198<Collaboration199image={LatexCollab}200alt="Two users editing the same LaTeX file simultaneously with visible cursors showing real-time collaboration"201>202<Paragraph>203Multiple users can <strong>edit the same file online</strong> at204the same time. Changes are{" "}205<strong>synchronized in real-time</strong> – you see the cursors206and edits of other collaborators as they type.207</Paragraph>208209<Paragraph>210Share your project privately with{" "}211<A href="https://doc.cocalc.com/project-settings.html#about-collaborators">212<strong>an unlimited number of collaborators</strong>213</A>214. Compilation status and PDF output are also synchronized between215everyone, ensuring that all collaborators experience the document216in exactly the same way.217</Paragraph>218</Collaboration>219220<Info221anchor="a-ai-formula"222icon="robot"223title="AI-powered formula assistant"224image={AIFormula}225alt="AI formula assistant dialog generating LaTeX formulas from natural language descriptions"226>227<Paragraph>228CoCalc's extensive integration with various AI language models229helps you typeset formulas.230</Paragraph>231<Paragraph>232You enter a description of your desired formula and{" "}233<strong>234a language model of your choice transforms it into proper LaTeX235code236</strong>237. The descriptions can come in various forms:238</Paragraph>239<Paragraph>240<Descriptions241layout="vertical"242bordered243column={1}244size={"small"}245>246<Descriptions.Item label="Natural language description">247<Text code>drake equation</Text>248</Descriptions.Item>249250<Descriptions.Item label="Simple algebraic notation">251<Text code>(a+b)^2 = a^2 + 2 a b + b^2</Text>252</Descriptions.Item>253254<Descriptions.Item label="Combination of both">255<Text code>256integral from 0 to infinity of (1+sin(x))/x^2 dx257</Text>258</Descriptions.Item>259</Descriptions>260</Paragraph>261<Paragraph>262Once you have a result you like, click "Insert" to add the formula263to your document.264</Paragraph>265</Info>266267<Info268anchor="a-darkmode"269icon={270<Icon271style={{ fontSize: "40px", color: "white" }}272unicode={DARK_MODE_ICON}273/>274}275title={276<span style={{ color: "white" }}>Dark Mode with PDF Support</span>277}278image={LatexDarkMode}279style={{ background: "rgb(50, 50, 50)", color: "white" }}280>281<Paragraph style={{ color: "white" }}>282Love{" "}283<span284style={{285background: "black",286color: "white",287padding: "2px 5px",288}}289>290dark mode291</span>292? CoCalc has you covered!293</Paragraph>294<Paragraph style={{ color: "white" }}>295The <LaTeX /> editor features dark UI elements as you'd expect,296but goes further by inverting the PDF viewer colors. This means297that even though your final PDF will have a white background, you298can view and edit it with a dark background and bright text for299comfortable night-time work.300</Paragraph>301<Paragraph style={{ color: COLORS.GRAY_L }}>302Note: You can quickly disable this PDF dark mode, to double check303the actual output.304</Paragraph>305</Info>306307<Info308anchor="a-multifile"309icon="folder-open"310title="Multi-file support"311image={LaTeXMultiFile}312alt="LaTeX editor showing multiple files with automatic discovery of included files"313>314<Paragraph>315Working with large LaTeX documents often means splitting your316content across multiple files using <Code>\include{"{...}"}</Code>{" "}317or <Code>\input{"{...}"}</Code> commands.{" "}318</Paragraph>319<Paragraph strong>320CoCalc automatically discovers all included files and makes321navigation easy.322</Paragraph>323<Paragraph>324Each entry shows a brief snippet of its beginning, making it easy325to identify the right file.326</Paragraph>327<Paragraph>328<strong>329<a href="#a-forwardinverse">Inverse search</a>330</strong>{" "}331works seamlessly with multi-file documents: double-click332anywhere in the PDF and CoCalc automatically opens the correct333subfile for you.334</Paragraph>335<Paragraph>336Learn more in the{" "}337<A href="https://doc.cocalc.com/latex#multi-file-support">338multi-file support documentation339</A>340.341</Paragraph>342</Info>343344<Info.Heading345anchor="a-calculations"346icon="calculator"347description={348<>349<Paragraph>350<strong>351Execute Python, Sage, or R code directly within your LaTeX352source353</strong>{" "}354to automatically generate figures, tables, formulas, and355results. Your computational code lives alongside your prose,356making your paper fully reproducible.357</Paragraph>358<Paragraph>359CoCalc supports{" "}360<A href="http://doc.sagemath.org/html/en/tutorial/sagetex.html">361SageTeX362</A>363, <A href="https://ctan.org/pkg/pythontex">PythonTeX</A>, and{" "}364<A href="https://yihui.name/knitr/">Knitr</A>. The code runs365during compilation, and the output is automatically included366in your PDF – change your code, recompile, and your document367updates.368</Paragraph>369</>370}371>372Embed Python, Sage or R code in <LaTeX /> documents373</Info.Heading>374375<Info376anchor="a-computational"377icon="laptop"378title="Full computational environment"379image={LatexPythontex}380alt="LaTeX editor with PythonTeX showing source code and PDF output with a damped oscillation plot"381wide382>383<Paragraph>384<strong>385Stop copying and pasting computational results into your papers.386</strong>{" "}387CoCalc gives you{" "}388<strong>full access to computational software</strong> directly389within your <LaTeX /> editor – seamlessly compute your results and390publish them in the same environment.391</Paragraph>392<Paragraph>393Run <A href="/features/python">Python</A>,{" "}394<A href="http://www.sagemath.org/">SageMath</A>,{" "}395<A href="/features/r-statistical-software">R</A>,{" "}396<A href="/features/julia">Julia</A>, and more right alongside your397document. All software is pre-installed and maintained – no setup398required.399</Paragraph>400<Paragraph>401Learn more on our <A href="/software">Available Software page</A>{" "}402or <A href="/features/jupyter-notebook">Jupyter Notebook page</A>.403</Paragraph>404</Info>405406<Info407anchor="a-sagetex"408title="SageTex"409icon="sagemath"410image={Sagetex}411alt="Editing LaTeX with SageTex code"412>413<Paragraph>414<strong>415<A href="http://doc.sagemath.org/html/en/tutorial/sagetex.html">416SageTeX417</A>{" "}418brings the power of{" "}419<A href="https://www.sagemath.org/">SageMath</A> symbolic420computation directly into your LaTeX documents.421</strong>422</Paragraph>423<Paragraph>424Write{" "}425<Code>426\sage{"{"}2 + 3{"}"}427</Code>{" "}428to get "5", use{" "}429<Code>430\sage{"{"}f.taylor(x, 0, 10){"}"}431</Code>{" "}432for Taylor expansions, and create plots with{" "}433<Code>434\sageplot{"{"}sin(x^2){"}"}435</Code>436. CoCalc automatically handles the full compilation pipeline:437</Paragraph>438<Paragraph>439<ul>440<li>441Runs the initial <LaTeX /> compilation pass442</li>443<li>444Executes <A href="https://www.sagemath.org/">SageMath</A> to445compute results, graphs, and images446</li>447<li>Completes the final compilation to produce your PDF</li>448</ul>449</Paragraph>450<Paragraph>451No manual intervention required – just write your code and452compile.453</Paragraph>454</Info>455456<Info457anchor="a-pythontex"458title="PythonTex"459icon="python"460image={Pythontex}461alt="Editing LaTeX with PythonTex code"462>463<Paragraph>464<strong>465<A href="https://ctan.org/pkg/pythontex">PythonTeX</A> executes466Python code within your LaTeX documents and typesets the467results.468</strong>469</Paragraph>470<Paragraph>471Use{" "}472<Code>473\py{"{"}2 + 4**2{"}"}474</Code>{" "}475to compute "18" inline, leverage the entire Python ecosystem476including NumPy, SciPy, and Matplotlib for plots, or perform477symbolic math with SymPy. Access to{" "}478<A href="/software/python">hundreds of Python libraries</A> means479you can analyze data, generate visualizations, and format results480without leaving your document.481</Paragraph>482<Paragraph>483CoCalc automatically detects PythonTeX usage and orchestrates the484compilation – you focus on your analysis, not the toolchain.485</Paragraph>486</Info>487488<Info489anchor="a-knitr"490title="R/Knitr"491icon="r"492image={Knitr}493alt="Editing LaTeX with R/Knitr code"494>495<Paragraph>496<strong>497<A href="https://yihui.name/knitr/">Knitr</A> brings R498statistical computing into your LaTeX workflow.499</strong>{" "}500Create <code>.Rnw</code> files that weave together statistical501analysis, data visualization, and professional typesetting.502</Paragraph>503<Paragraph>504Perfect for statistical reports, academic papers, and data-driven505research. CoCalc handles everything automatically:506</Paragraph>507<Paragraph>508<ul>509<li>510<A href="/software/r">Thousands of R packages</A>{" "}511pre-installed and maintained512</li>513<li>Full compilation pipeline from R code to final PDF</li>514<li>515<A href="#a-forwardinverse">516<strong>Forward and inverse search</strong>517</A>{" "}518between <code>.Rnw</code> source and PDF output519</li>520</ul>521</Paragraph>522<Paragraph>523Run your statistical analysis and generate publication-ready524documents in one integrated environment.525</Paragraph>526</Info>527528<Info.Heading529description={530<>531The following are some specific features of editing <LaTeX /> in532CoCalc.533<br />534There is also more{" "}535<A href="https://doc.cocalc.com/latex.html">536comprehensive documentation537</A>538.539</>540}541>542<LaTeX /> Editing Features543</Info.Heading>544545<Info546anchor="a-forwardinverse"547title="Forward and Inverse search"548icon="sync"549video={[550"features/latex-forward-inverse-20251006.webm",551"features/latex-forward-inverse-20251006.mp4",552]}553wide554alt="Video showing forward and inverse search in a LaTeX document"555>556<Paragraph>557<strong>Navigate effortlessly between source and PDF.</strong>558</Paragraph>559<Paragraph>560This speeds up your editing workflow, especially in large561documents.562</Paragraph>563<Paragraph>564<strong>Forward Search:</strong> Click in your LaTeX source to565jump to the corresponding location in the PDF preview.566</Paragraph>567<Paragraph>568<strong>Inverse Search:</strong> Double-click anywhere in the PDF569to jump back to the corresponding location in your source code.570You can also enable automatic sync mode to keep your source editor571aligned with the PDF as you scroll.572</Paragraph>573<Paragraph>574Powered by{" "}575<A href="https://github.com/jlaurens/synctex">SyncTeX</A>, working576seamlessly in the background.577</Paragraph>578</Info>579580<Info581anchor="a-environments"582icon="tex-file"583title={584<>585Managed <LaTeX /> environments586</>587}588image={CustomCommand}589alt="Menu showing the different LaTeX engines in CoCalc"590>591<Paragraph>592CoCalc makes sure that your desired <LaTeX /> engine is available593and ready to use. You can choose between{" "}594<strong>595<A href="http://www.tug.org/applications/pdftex/">PDF Latex</A>596</strong>597,{" "}598<strong>599<A href="http://xetex.sourceforge.net/">XeLaTeX</A>600</strong>{" "}601or{" "}602<strong>603<A href="http://www.luatex.org/">LuaTeX</A>604</strong>605.606</Paragraph>607<Paragraph>608Many packages and utilities like{" "}609<A href="https://sourceforge.net/projects/pgf/">PGF and TikZ</A>{" "}610are pre-installed.611</Paragraph>612<Paragraph>613Behind the scenes,{" "}614<A href="http://mg.readthedocs.io/latexmk.html">LatexMK</A> is615configured to manage the compilation process.616</Paragraph>617<Paragraph>618It is also possible to{" "}619<strong>fully customize the compilation command</strong>, so you620can bring your own shell script or even use a Makefile!621</Paragraph>622</Info>623624<Info625anchor="a-timetravel"626title="TimeTravel"627icon="history"628image={LatexTimetravel}629alt={630"Using the TimeTravel slider to see what changed in a LaTeX document"631}632>633<Paragraph>634The <strong>TimeTravel feature</strong> is specific to the CoCalc635platform. It records all changes in the document in fine detail.636You can go back and forth in time using a slider across thousands637of changes to recover your previous edits.638</Paragraph>639<Paragraph>640This is especially helpful for pinpointing which of the recent641changes caused a <strong>compilation error</strong>. You can see642the recent changes and exactly where the modifications happened,643and who made them.644</Paragraph>645</Info>646647<Info648anchor="a-chat"649title="Side Chat"650icon="comment"651image={Sidechat}652alt="Chatting about a LaTeX document right next to that document"653>654<Paragraph>655A{" "}656<strong>657<A href="https://doc.cocalc.com/chat.html">side-by-side chat</A>658</strong>{" "}659for each <LaTeX /> file lets you discuss your content with660collaborators or give feedback to your students while they are661working on their assignments.662</Paragraph>663<Paragraph>664<strong>Query AI language models</strong> directly in the chat to665get help with your document. Ask questions about LaTeX syntax,666request suggestions for improving your writing, or discuss the667content of your document with AI assistants.668</Paragraph>669<Paragraph>670Collaborators who are offline will be notified about new messages671the next time they sign in. If you @mention them, they receive an672email notification.673</Paragraph>674<Paragraph>675Chat messages also support{" "}676<A href="https://en.wikipedia.org/wiki/Markdown">Markdown</A>{" "}677formatting with <LaTeX /> formulas.{" "}678</Paragraph>679</Info>680681<Backups />682<Publishing />683684<Comparison685name="latex"686disclaimer687title={688<h2 style={{ textAlign: "center" }}>689<Icon name="bolt" /> <LaTeX /> in CoCalc versus the competition690</h2>691}692/>693694<SignIn startup={<LaTeX />} />695</Layout.Content>696<Footer />697</Layout>698</Customize>699);700}701702export async function getServerSideProps(context) {703return await withCustomize({ context });704}705706707