I would like to execute a command which produces text, but not have that text visible anywhere inside the document. Can we put the command inside a box, which clips other text, such as in the middle of the page? Normally, this would look ugly (a box text rendered on top of other text). Can we make the text invisible? That is, have a box smack dab in the middle of the page full of invisible text? Or what if we place the box of text outside of the page margins. That way, the text will be there, but not visible?
Asked
Active
Viewed 720 times
0
-
See also https://tex.stackexchange.com/questions/367513/regarding-pages-that-are-not-visible-in-pdf – John Kormylo Jan 11 '19 at 03:35
-
1Are you specifically talking about writing this text as part of other text? That is, within some textual paragraph flow? Or do you just want to place the invisible text at an arbitrary position on the page? The latter seems odd, since you're placing something that can't be seen, so what's the point...? – Werner Jan 11 '19 at 03:56
-
Maybe https://tex.stackexchange.com/q/8981/35864 can help – moewe Jan 11 '19 at 04:16
-
see also https://tex.stackexchange.com/q/243874/35864 – moewe Jan 11 '19 at 04:21
-
This is a duplicate of Retain side-effects but discard command output, but not of Hiding part of text leaving blank space. – Circumscribe Jan 11 '19 at 12:52
1 Answers
0
The following appears to work:
\documentclass{minimal}
\usepackage[pscoord]{eso-pic}
\newcommand{\placetextbox}[3]{
\setbox0=\hbox{#3}
\AddToShipoutPictureFG*{
\put(\LenToUnit{#1\paperwidth},\LenToUnit{#2\paperheight}){\vtop{{\null}\makebox[0pt][c]{#3}}}%
}
}
\begin{document}
This is Some Visible Text
\placetextbox{0.5}{0.5}{\phantom{INVISIBLE TEXT HERE}}
\end{document}
You simply replace INVISIBLE TEXT HERE with the command you want executed, but do not want the output text from.
The solution above is based on Werner's answer to a different question. However, in that case, they were not trying to make the text invisible, or execute a command while discarding the resultant text.
For example, if you are using bibtex and you want something in your bibliography without having any in-text citations, then INVISIBLE TEXT HERE might be something like:
\cite{Miller78} \cite{Bubba94}
IdleCustard
- 1,194
-
1
\placetextboxlooks like it is based on https://tex.stackexchange.com/q/24663/35864. If that is the case the courteous thing to do is to acknowledge the earlier work that you build on. – moewe Jan 11 '19 at 04:09 -
4The standard way to get references in the bibliography without citing them explicitly in the text is
\nocite.\nocite{sigfridsson,worman}will add the two entriessigfridssonandwormanto the bibliography even if they have not been cited.\nocite{*}adds all available entries to the bibliography. (See https://tex.stackexchange.com/q/17128/35864) – moewe Jan 11 '19 at 04:10 -
-
the question as asked would have been answered by simply
\sbox0=\hbox{...}as that executes the commands in ... but (if you don't use the box) hides them. It would not answer your cite use case but that was not in the question. (and this is completely the wrong approach for that use case as moewe has pointed out) Also as you have used\phantomthis answer would work for\citebut not for example anything using\label. – David Carlisle Jan 13 '19 at 12:26