Anki: Displayed size does not match specified size
up vote
1
down vote
favorite
In Anki, the sizes I specify in LaTeX encoding do not match those that are displayed.
MWE: Leaving the header and footer at the Anki default of
documentclass[12pt]{article}
special{papersize=3in,5in}
usepackage[utf8]{inputenc}
usepackage{amssymb,amsmath}
pagestyle{empty}
setlength{parindent}{0in}
begin{document}
and
end{document}
respectively, typing [latex]rule{1cm}{1cm}[/latex]
(and adjusting the note's CSS so that the produced image is not resized with img{max-height:none; max-width:none;}
) will display an approximately 1.75cm by 1.75cm square, as opposed to the expected 1cm by 1cm square.
How can I adjust this so that the size I specify in LaTeX is accurately displayed?
The obvious solution would be some way to scale an entire LaTeX document, but my searches for such have been unfruitful.
I would prefer not to resort to re-scaling the actual images produced by Anki (hence the CSS), as this renders them blurry.
What I have tried:
Adjusting the font size will not fix the MWE above, as LaTeX still
thinks that 1cm is ~1.75cm.Adjusting the paper size does not seem to do anything.
What others have suggested, and I have tried:
scalebox
andresizebox
(after puttingusepackage{graphicx}
/usepackage{graphics}
in header) do not resize anything visually, but can cause other LaTeX objects to register them as smaller. For example, with the modified header and default footer,
[latex]scalebox{0.5}{rule{1cm}{1cm}}foo bar[/latex]
will produce a >1cm box blocking the word
foo
, followed by the wordbar
.
(Suggested by @John Kormylo)
Edit: Info on anki LaTeX compile process. Removed, see my answer if you really want to know.
Edit: Semi-failed attempt, Removed, see my answer if you really want to know.
scaling anki
add a comment |
up vote
1
down vote
favorite
In Anki, the sizes I specify in LaTeX encoding do not match those that are displayed.
MWE: Leaving the header and footer at the Anki default of
documentclass[12pt]{article}
special{papersize=3in,5in}
usepackage[utf8]{inputenc}
usepackage{amssymb,amsmath}
pagestyle{empty}
setlength{parindent}{0in}
begin{document}
and
end{document}
respectively, typing [latex]rule{1cm}{1cm}[/latex]
(and adjusting the note's CSS so that the produced image is not resized with img{max-height:none; max-width:none;}
) will display an approximately 1.75cm by 1.75cm square, as opposed to the expected 1cm by 1cm square.
How can I adjust this so that the size I specify in LaTeX is accurately displayed?
The obvious solution would be some way to scale an entire LaTeX document, but my searches for such have been unfruitful.
I would prefer not to resort to re-scaling the actual images produced by Anki (hence the CSS), as this renders them blurry.
What I have tried:
Adjusting the font size will not fix the MWE above, as LaTeX still
thinks that 1cm is ~1.75cm.Adjusting the paper size does not seem to do anything.
What others have suggested, and I have tried:
scalebox
andresizebox
(after puttingusepackage{graphicx}
/usepackage{graphics}
in header) do not resize anything visually, but can cause other LaTeX objects to register them as smaller. For example, with the modified header and default footer,
[latex]scalebox{0.5}{rule{1cm}{1cm}}foo bar[/latex]
will produce a >1cm box blocking the word
foo
, followed by the wordbar
.
(Suggested by @John Kormylo)
Edit: Info on anki LaTeX compile process. Removed, see my answer if you really want to know.
Edit: Semi-failed attempt, Removed, see my answer if you really want to know.
scaling anki
I would say this is a Anki problem rather than a LaTeX problem. For example sbox0{rule{1cm}{1cm}}theht0parthewd0 should return 28.45274pt (1cm).
– John Kormylo
Oct 3 '17 at 19:57
You could use scalebox to compensate, though.
– John Kormylo
Oct 3 '17 at 19:58
I learned that dvipng does not honor the special{papersize=width,height} command.
– dubiousjim
Jan 2 at 11:06
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
In Anki, the sizes I specify in LaTeX encoding do not match those that are displayed.
MWE: Leaving the header and footer at the Anki default of
documentclass[12pt]{article}
special{papersize=3in,5in}
usepackage[utf8]{inputenc}
usepackage{amssymb,amsmath}
pagestyle{empty}
setlength{parindent}{0in}
begin{document}
and
end{document}
respectively, typing [latex]rule{1cm}{1cm}[/latex]
(and adjusting the note's CSS so that the produced image is not resized with img{max-height:none; max-width:none;}
) will display an approximately 1.75cm by 1.75cm square, as opposed to the expected 1cm by 1cm square.
How can I adjust this so that the size I specify in LaTeX is accurately displayed?
The obvious solution would be some way to scale an entire LaTeX document, but my searches for such have been unfruitful.
I would prefer not to resort to re-scaling the actual images produced by Anki (hence the CSS), as this renders them blurry.
What I have tried:
Adjusting the font size will not fix the MWE above, as LaTeX still
thinks that 1cm is ~1.75cm.Adjusting the paper size does not seem to do anything.
What others have suggested, and I have tried:
scalebox
andresizebox
(after puttingusepackage{graphicx}
/usepackage{graphics}
in header) do not resize anything visually, but can cause other LaTeX objects to register them as smaller. For example, with the modified header and default footer,
[latex]scalebox{0.5}{rule{1cm}{1cm}}foo bar[/latex]
will produce a >1cm box blocking the word
foo
, followed by the wordbar
.
(Suggested by @John Kormylo)
Edit: Info on anki LaTeX compile process. Removed, see my answer if you really want to know.
Edit: Semi-failed attempt, Removed, see my answer if you really want to know.
scaling anki
In Anki, the sizes I specify in LaTeX encoding do not match those that are displayed.
MWE: Leaving the header and footer at the Anki default of
documentclass[12pt]{article}
special{papersize=3in,5in}
usepackage[utf8]{inputenc}
usepackage{amssymb,amsmath}
pagestyle{empty}
setlength{parindent}{0in}
begin{document}
and
end{document}
respectively, typing [latex]rule{1cm}{1cm}[/latex]
(and adjusting the note's CSS so that the produced image is not resized with img{max-height:none; max-width:none;}
) will display an approximately 1.75cm by 1.75cm square, as opposed to the expected 1cm by 1cm square.
How can I adjust this so that the size I specify in LaTeX is accurately displayed?
The obvious solution would be some way to scale an entire LaTeX document, but my searches for such have been unfruitful.
I would prefer not to resort to re-scaling the actual images produced by Anki (hence the CSS), as this renders them blurry.
What I have tried:
Adjusting the font size will not fix the MWE above, as LaTeX still
thinks that 1cm is ~1.75cm.Adjusting the paper size does not seem to do anything.
What others have suggested, and I have tried:
scalebox
andresizebox
(after puttingusepackage{graphicx}
/usepackage{graphics}
in header) do not resize anything visually, but can cause other LaTeX objects to register them as smaller. For example, with the modified header and default footer,
[latex]scalebox{0.5}{rule{1cm}{1cm}}foo bar[/latex]
will produce a >1cm box blocking the word
foo
, followed by the wordbar
.
(Suggested by @John Kormylo)
Edit: Info on anki LaTeX compile process. Removed, see my answer if you really want to know.
Edit: Semi-failed attempt, Removed, see my answer if you really want to know.
scaling anki
scaling anki
edited Oct 13 '17 at 0:00
asked Oct 3 '17 at 2:14
Dragon
164
164
I would say this is a Anki problem rather than a LaTeX problem. For example sbox0{rule{1cm}{1cm}}theht0parthewd0 should return 28.45274pt (1cm).
– John Kormylo
Oct 3 '17 at 19:57
You could use scalebox to compensate, though.
– John Kormylo
Oct 3 '17 at 19:58
I learned that dvipng does not honor the special{papersize=width,height} command.
– dubiousjim
Jan 2 at 11:06
add a comment |
I would say this is a Anki problem rather than a LaTeX problem. For example sbox0{rule{1cm}{1cm}}theht0parthewd0 should return 28.45274pt (1cm).
– John Kormylo
Oct 3 '17 at 19:57
You could use scalebox to compensate, though.
– John Kormylo
Oct 3 '17 at 19:58
I learned that dvipng does not honor the special{papersize=width,height} command.
– dubiousjim
Jan 2 at 11:06
I would say this is a Anki problem rather than a LaTeX problem. For example sbox0{rule{1cm}{1cm}}theht0parthewd0 should return 28.45274pt (1cm).
– John Kormylo
Oct 3 '17 at 19:57
I would say this is a Anki problem rather than a LaTeX problem. For example sbox0{rule{1cm}{1cm}}theht0parthewd0 should return 28.45274pt (1cm).
– John Kormylo
Oct 3 '17 at 19:57
You could use scalebox to compensate, though.
– John Kormylo
Oct 3 '17 at 19:58
You could use scalebox to compensate, though.
– John Kormylo
Oct 3 '17 at 19:58
I learned that dvipng does not honor the special{papersize=width,height} command.
– dubiousjim
Jan 2 at 11:06
I learned that dvipng does not honor the special{papersize=width,height} command.
– dubiousjim
Jan 2 at 11:06
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
The previous solution I found (previous solution) uses the standalone
class, and does not handle the graphicx
package well, nor images, which are extremely useful in anki. To fix this, I have instead figured out the following.
In Anki, putting the following as the LaTeX header:
documentclass[12pt]{article}
RequirePackage{graphicx}
RequirePackage{environ}
pagestyle{empty}
setlength{parindent}{0in}
NewEnviron{ankicard}{fontsize{16}{19}selectfontscalebox{0.6}{BODY}}{}
begin{document}
begin{ankicard}
and the following as the footer:
end{ankicard}end{document}
and, in the Edit LaTeX build process
addon to anki, putting the following:
#original setting
#newLaTeX =
#[
# ["latex", "-interaction=nonstopmode", "tmp.tex"],
# ["dvipng", "-D", "200", "-T", "tight", "tmp.dvi", "-o", "tmp.png"]
#]
# ======
#Setting for pdflatex compilation
newLaTeX =
[
["pdflatex", "-interaction=nonstopmode", "tmp.tex"],
["pdfcrop", "tmp.pdf"],
["pdftoppm", "-png", "-r", "200", "tmp-crop.pdf", "tmp"],
["ankirename.bat"]
]
# make the changes
import anki.latex
anki.latex.latexCmds = newLaTeX
(only the second list is new, rest comes w/ addon), and putting ankirename.bat
somewhere in your path, with the contents
rename tmp-1.png tmp.png
Should scale all (newly generated) LaTeX in anki to the appropriate size. If it does not, you can fiddle with the 0.6
parameter in scalebox
in the ankicard
environment of the LaTeX header. This should also allow placing and scaling graphics in anki, and should allow LaTeX to automatically wrap any text that you type that is too long without the varwidth
package that the standalone
class requires to do so, which seems to conflict with graphicx
.
The explanation:
As the previous solution has said, some packages require the pdflatex
compiler, which does not always output all of the necessary data in any produced .dvi
files, so not only will anki's default use of latex ...
not work, the second command of dvipng ...
won't work either, so we have to change both of these.
Switching to pdflatex ...
compilation is straightforward, ripped right from the linked answer. This will produce a file called tmp.pdf
However, if we want to use the article
document type (as anki uses by default) to allow inserting and scaling images and such, we can't use the standalone
class like the other answer mentions, so not only do we not get the automatic compilation to .png
that standalone
provides, we don't get its automatic cropping either. Fortunately, these are both easy to fix, with pdfcrop
, which produces a file tmp-crop.pdf
, and pdftoppm
, which produces a file called tmp-1.png
. (Note: if pdfcrop --debug
is saying that it both can and can't find ghostscript, double check that C:WindowsSystem32
is in your path.)
Lastly, anki does not actually use a shell to execute these commands, it simply runs the executables. But because rename
and mv
are not (as I infer from the fact that they produce errors here) actual programs, but rather functions in a shell, we cannot put rename tmp-1.png tmp.png
directly into the LaTeX build process file. Instead, we just add a layer of indirection and have it call a .bat
file that does that for us.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f394311%2fanki-displayed-size-does-not-match-specified-size%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
The previous solution I found (previous solution) uses the standalone
class, and does not handle the graphicx
package well, nor images, which are extremely useful in anki. To fix this, I have instead figured out the following.
In Anki, putting the following as the LaTeX header:
documentclass[12pt]{article}
RequirePackage{graphicx}
RequirePackage{environ}
pagestyle{empty}
setlength{parindent}{0in}
NewEnviron{ankicard}{fontsize{16}{19}selectfontscalebox{0.6}{BODY}}{}
begin{document}
begin{ankicard}
and the following as the footer:
end{ankicard}end{document}
and, in the Edit LaTeX build process
addon to anki, putting the following:
#original setting
#newLaTeX =
#[
# ["latex", "-interaction=nonstopmode", "tmp.tex"],
# ["dvipng", "-D", "200", "-T", "tight", "tmp.dvi", "-o", "tmp.png"]
#]
# ======
#Setting for pdflatex compilation
newLaTeX =
[
["pdflatex", "-interaction=nonstopmode", "tmp.tex"],
["pdfcrop", "tmp.pdf"],
["pdftoppm", "-png", "-r", "200", "tmp-crop.pdf", "tmp"],
["ankirename.bat"]
]
# make the changes
import anki.latex
anki.latex.latexCmds = newLaTeX
(only the second list is new, rest comes w/ addon), and putting ankirename.bat
somewhere in your path, with the contents
rename tmp-1.png tmp.png
Should scale all (newly generated) LaTeX in anki to the appropriate size. If it does not, you can fiddle with the 0.6
parameter in scalebox
in the ankicard
environment of the LaTeX header. This should also allow placing and scaling graphics in anki, and should allow LaTeX to automatically wrap any text that you type that is too long without the varwidth
package that the standalone
class requires to do so, which seems to conflict with graphicx
.
The explanation:
As the previous solution has said, some packages require the pdflatex
compiler, which does not always output all of the necessary data in any produced .dvi
files, so not only will anki's default use of latex ...
not work, the second command of dvipng ...
won't work either, so we have to change both of these.
Switching to pdflatex ...
compilation is straightforward, ripped right from the linked answer. This will produce a file called tmp.pdf
However, if we want to use the article
document type (as anki uses by default) to allow inserting and scaling images and such, we can't use the standalone
class like the other answer mentions, so not only do we not get the automatic compilation to .png
that standalone
provides, we don't get its automatic cropping either. Fortunately, these are both easy to fix, with pdfcrop
, which produces a file tmp-crop.pdf
, and pdftoppm
, which produces a file called tmp-1.png
. (Note: if pdfcrop --debug
is saying that it both can and can't find ghostscript, double check that C:WindowsSystem32
is in your path.)
Lastly, anki does not actually use a shell to execute these commands, it simply runs the executables. But because rename
and mv
are not (as I infer from the fact that they produce errors here) actual programs, but rather functions in a shell, we cannot put rename tmp-1.png tmp.png
directly into the LaTeX build process file. Instead, we just add a layer of indirection and have it call a .bat
file that does that for us.
add a comment |
up vote
0
down vote
The previous solution I found (previous solution) uses the standalone
class, and does not handle the graphicx
package well, nor images, which are extremely useful in anki. To fix this, I have instead figured out the following.
In Anki, putting the following as the LaTeX header:
documentclass[12pt]{article}
RequirePackage{graphicx}
RequirePackage{environ}
pagestyle{empty}
setlength{parindent}{0in}
NewEnviron{ankicard}{fontsize{16}{19}selectfontscalebox{0.6}{BODY}}{}
begin{document}
begin{ankicard}
and the following as the footer:
end{ankicard}end{document}
and, in the Edit LaTeX build process
addon to anki, putting the following:
#original setting
#newLaTeX =
#[
# ["latex", "-interaction=nonstopmode", "tmp.tex"],
# ["dvipng", "-D", "200", "-T", "tight", "tmp.dvi", "-o", "tmp.png"]
#]
# ======
#Setting for pdflatex compilation
newLaTeX =
[
["pdflatex", "-interaction=nonstopmode", "tmp.tex"],
["pdfcrop", "tmp.pdf"],
["pdftoppm", "-png", "-r", "200", "tmp-crop.pdf", "tmp"],
["ankirename.bat"]
]
# make the changes
import anki.latex
anki.latex.latexCmds = newLaTeX
(only the second list is new, rest comes w/ addon), and putting ankirename.bat
somewhere in your path, with the contents
rename tmp-1.png tmp.png
Should scale all (newly generated) LaTeX in anki to the appropriate size. If it does not, you can fiddle with the 0.6
parameter in scalebox
in the ankicard
environment of the LaTeX header. This should also allow placing and scaling graphics in anki, and should allow LaTeX to automatically wrap any text that you type that is too long without the varwidth
package that the standalone
class requires to do so, which seems to conflict with graphicx
.
The explanation:
As the previous solution has said, some packages require the pdflatex
compiler, which does not always output all of the necessary data in any produced .dvi
files, so not only will anki's default use of latex ...
not work, the second command of dvipng ...
won't work either, so we have to change both of these.
Switching to pdflatex ...
compilation is straightforward, ripped right from the linked answer. This will produce a file called tmp.pdf
However, if we want to use the article
document type (as anki uses by default) to allow inserting and scaling images and such, we can't use the standalone
class like the other answer mentions, so not only do we not get the automatic compilation to .png
that standalone
provides, we don't get its automatic cropping either. Fortunately, these are both easy to fix, with pdfcrop
, which produces a file tmp-crop.pdf
, and pdftoppm
, which produces a file called tmp-1.png
. (Note: if pdfcrop --debug
is saying that it both can and can't find ghostscript, double check that C:WindowsSystem32
is in your path.)
Lastly, anki does not actually use a shell to execute these commands, it simply runs the executables. But because rename
and mv
are not (as I infer from the fact that they produce errors here) actual programs, but rather functions in a shell, we cannot put rename tmp-1.png tmp.png
directly into the LaTeX build process file. Instead, we just add a layer of indirection and have it call a .bat
file that does that for us.
add a comment |
up vote
0
down vote
up vote
0
down vote
The previous solution I found (previous solution) uses the standalone
class, and does not handle the graphicx
package well, nor images, which are extremely useful in anki. To fix this, I have instead figured out the following.
In Anki, putting the following as the LaTeX header:
documentclass[12pt]{article}
RequirePackage{graphicx}
RequirePackage{environ}
pagestyle{empty}
setlength{parindent}{0in}
NewEnviron{ankicard}{fontsize{16}{19}selectfontscalebox{0.6}{BODY}}{}
begin{document}
begin{ankicard}
and the following as the footer:
end{ankicard}end{document}
and, in the Edit LaTeX build process
addon to anki, putting the following:
#original setting
#newLaTeX =
#[
# ["latex", "-interaction=nonstopmode", "tmp.tex"],
# ["dvipng", "-D", "200", "-T", "tight", "tmp.dvi", "-o", "tmp.png"]
#]
# ======
#Setting for pdflatex compilation
newLaTeX =
[
["pdflatex", "-interaction=nonstopmode", "tmp.tex"],
["pdfcrop", "tmp.pdf"],
["pdftoppm", "-png", "-r", "200", "tmp-crop.pdf", "tmp"],
["ankirename.bat"]
]
# make the changes
import anki.latex
anki.latex.latexCmds = newLaTeX
(only the second list is new, rest comes w/ addon), and putting ankirename.bat
somewhere in your path, with the contents
rename tmp-1.png tmp.png
Should scale all (newly generated) LaTeX in anki to the appropriate size. If it does not, you can fiddle with the 0.6
parameter in scalebox
in the ankicard
environment of the LaTeX header. This should also allow placing and scaling graphics in anki, and should allow LaTeX to automatically wrap any text that you type that is too long without the varwidth
package that the standalone
class requires to do so, which seems to conflict with graphicx
.
The explanation:
As the previous solution has said, some packages require the pdflatex
compiler, which does not always output all of the necessary data in any produced .dvi
files, so not only will anki's default use of latex ...
not work, the second command of dvipng ...
won't work either, so we have to change both of these.
Switching to pdflatex ...
compilation is straightforward, ripped right from the linked answer. This will produce a file called tmp.pdf
However, if we want to use the article
document type (as anki uses by default) to allow inserting and scaling images and such, we can't use the standalone
class like the other answer mentions, so not only do we not get the automatic compilation to .png
that standalone
provides, we don't get its automatic cropping either. Fortunately, these are both easy to fix, with pdfcrop
, which produces a file tmp-crop.pdf
, and pdftoppm
, which produces a file called tmp-1.png
. (Note: if pdfcrop --debug
is saying that it both can and can't find ghostscript, double check that C:WindowsSystem32
is in your path.)
Lastly, anki does not actually use a shell to execute these commands, it simply runs the executables. But because rename
and mv
are not (as I infer from the fact that they produce errors here) actual programs, but rather functions in a shell, we cannot put rename tmp-1.png tmp.png
directly into the LaTeX build process file. Instead, we just add a layer of indirection and have it call a .bat
file that does that for us.
The previous solution I found (previous solution) uses the standalone
class, and does not handle the graphicx
package well, nor images, which are extremely useful in anki. To fix this, I have instead figured out the following.
In Anki, putting the following as the LaTeX header:
documentclass[12pt]{article}
RequirePackage{graphicx}
RequirePackage{environ}
pagestyle{empty}
setlength{parindent}{0in}
NewEnviron{ankicard}{fontsize{16}{19}selectfontscalebox{0.6}{BODY}}{}
begin{document}
begin{ankicard}
and the following as the footer:
end{ankicard}end{document}
and, in the Edit LaTeX build process
addon to anki, putting the following:
#original setting
#newLaTeX =
#[
# ["latex", "-interaction=nonstopmode", "tmp.tex"],
# ["dvipng", "-D", "200", "-T", "tight", "tmp.dvi", "-o", "tmp.png"]
#]
# ======
#Setting for pdflatex compilation
newLaTeX =
[
["pdflatex", "-interaction=nonstopmode", "tmp.tex"],
["pdfcrop", "tmp.pdf"],
["pdftoppm", "-png", "-r", "200", "tmp-crop.pdf", "tmp"],
["ankirename.bat"]
]
# make the changes
import anki.latex
anki.latex.latexCmds = newLaTeX
(only the second list is new, rest comes w/ addon), and putting ankirename.bat
somewhere in your path, with the contents
rename tmp-1.png tmp.png
Should scale all (newly generated) LaTeX in anki to the appropriate size. If it does not, you can fiddle with the 0.6
parameter in scalebox
in the ankicard
environment of the LaTeX header. This should also allow placing and scaling graphics in anki, and should allow LaTeX to automatically wrap any text that you type that is too long without the varwidth
package that the standalone
class requires to do so, which seems to conflict with graphicx
.
The explanation:
As the previous solution has said, some packages require the pdflatex
compiler, which does not always output all of the necessary data in any produced .dvi
files, so not only will anki's default use of latex ...
not work, the second command of dvipng ...
won't work either, so we have to change both of these.
Switching to pdflatex ...
compilation is straightforward, ripped right from the linked answer. This will produce a file called tmp.pdf
However, if we want to use the article
document type (as anki uses by default) to allow inserting and scaling images and such, we can't use the standalone
class like the other answer mentions, so not only do we not get the automatic compilation to .png
that standalone
provides, we don't get its automatic cropping either. Fortunately, these are both easy to fix, with pdfcrop
, which produces a file tmp-crop.pdf
, and pdftoppm
, which produces a file called tmp-1.png
. (Note: if pdfcrop --debug
is saying that it both can and can't find ghostscript, double check that C:WindowsSystem32
is in your path.)
Lastly, anki does not actually use a shell to execute these commands, it simply runs the executables. But because rename
and mv
are not (as I infer from the fact that they produce errors here) actual programs, but rather functions in a shell, we cannot put rename tmp-1.png tmp.png
directly into the LaTeX build process file. Instead, we just add a layer of indirection and have it call a .bat
file that does that for us.
answered Oct 12 '17 at 23:57
Dragon
164
164
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f394311%2fanki-displayed-size-does-not-match-specified-size%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I would say this is a Anki problem rather than a LaTeX problem. For example sbox0{rule{1cm}{1cm}}theht0parthewd0 should return 28.45274pt (1cm).
– John Kormylo
Oct 3 '17 at 19:57
You could use scalebox to compensate, though.
– John Kormylo
Oct 3 '17 at 19:58
I learned that dvipng does not honor the special{papersize=width,height} command.
– dubiousjim
Jan 2 at 11:06