Skip to content

Commit

Permalink
use the standalone document class to simplify the tikz template (#1985)
Browse files Browse the repository at this point in the history
[standalone](https://ctan.org/pkg/standalone) supports both PDFLaTeX and XeLaTeX (the latter means it will be much easier to support CJK); in addition, standalone doesn't need the preview package, and preview is too complicated
  • Loading branch information
XiangyunHuang authored Apr 13, 2021
1 parent 00ae3ec commit 1f3bd75
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

- For `kable(x, format = 'simple')`, it no longer generates a `pipe` table but a `simple` table instead when `x` has only one column (thanks, @alusiani, #1968). For `kable(x, format = 'pipe')`, it no longer warns when `x` has no column names, but just generate an empty table header.

- For `tikz` code chunks, the default LaTeX template uses `\documentclass[tikz]{standalone}` instead of `\documentclass{article}` and \usepackage{preview}` now (thanks, @XiangyunHuang, #1985).

# CHANGES IN knitr VERSION 1.31

## NEW FEATURES
Expand Down
7 changes: 1 addition & 6 deletions inst/misc/tikz2pdf.tex
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
\documentclass{article}
\include{preview}
\usepackage[pdftex,active,tightpage]{preview}
\documentclass[tikz]{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix}
%% EXTRA_TIKZ_PREAMBLE_CODE %%
\begin{document}
\begin{preview}
%% TIKZ_CODE %%
\end{preview}
\end{document}

3 comments on commit 1f3bd75

@yihui
Copy link
Owner

@yihui yihui commented on 1f3bd75 Apr 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krivit Does this change look good to you? I rarely use tikz myself, so I'd like another pair of eyes to double check it. Thanks!

@krivit
Copy link
Contributor

@krivit krivit commented on 1f3bd75 Apr 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yihui , looks like a definite net improvement to me. A small caveat is that there are certain things (such as as display equations and paragraph breaks) that standalone will typeset differently from article/preview.

@yihui
Copy link
Owner

@yihui yihui commented on 1f3bd75 Apr 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thanks a lot for your feedback!

Please sign in to comment.