6

I want that my tex-editor shows me the 2-holes of a A4 sheet, but don't appear in the output PDF.

Note: I don't want to use % and comment the circle's out and compile it again. The reason is, that I will have thousands of .tex files and it wouldn't be efficient to compile every time twice.

enter image description here

If i make a circle with tikz, then the output PDF will have the 2 holes:

    \documentclass[11pt,twoside,german]{article}
        \usepackage[T1]{fontenc}
        \usepackage[sfdefault,condensed,light]{roboto}
        \usepackage[utf8]{inputenc}
        \usepackage[paperwidth=210 mm,paperheight=297 mm,left=0mm,right=0mm,top=0mm,bottom=0mm]{geometry}
        \usepackage{eso-pic} 
        \usepackage{tikz}
    \usepackage{scrextend}
    \begin{document}
    \ClearShipoutPicture
        \AddToShipoutPicture{%
            \AtPageLowerLeft{%
                \begin{tikzpicture}%[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
                    \clip(0,0) rectangle (21,29.7);
                    \draw [fill=black!10!] (1.2,10.85) circle (3mm);
                    \draw [fill=black!10!] (1.2,18.85) circle (3mm);
                \end{tikzpicture} 
            }
        }

    some text

    \vspace*{10cm} 

    some times i need this part

    \vspace*{2cm}

    \begin{addmargin}[2cm]{2cm}
    some times i add margins
    \end{addmargin}
    \end{document}

How can I hide these 2 holes at the output PDF, but see them in the tex-editor? Thanks for helping!

DG'
  • 21,727
  • HI ! What do you mean by editor ? – flav Feb 10 '21 at 08:35
  • TexStudio, TeXShop etc.... – Bilal Yilmaz Feb 10 '21 at 08:37
  • Nice trick, I'd comment out the part which creates the holes and compile it again – TVL Feb 10 '21 at 08:41
  • Yes i did this first. But i will have thousends of .tex files. And going everytime inside the .tex file and compiling it 2 times will not be efficient. And also i could forget it to comment it at the end, which is not good – Bilal Yilmaz Feb 10 '21 at 08:43
  • Good point and I got your point in showing them in the editor. I've never seen that somewhere in the setting of TeXStudio, at least. – TVL Feb 10 '21 at 08:45
  • Silly but honest question; If you have the holes in the print, won't they be real holes once the page is hole-punched, so it doesn't really matter if the holes are printed? – Habi Feb 10 '21 at 15:48
  • the A4 sheets will have pre-punched holes. So if the printer prints on the holes, maybe the colors will released and damage the printer. – Bilal Yilmaz Feb 11 '21 at 08:04

1 Answers1

9

You can put the holes on a separate OCG layer, that is not printed:

 \documentclass[11pt,twoside,german]{article}
        \usepackage[T1]{fontenc}
        \usepackage[sfdefault,condensed,light]{roboto}
        \usepackage[utf8]{inputenc}
        \usepackage[paperwidth=210 mm,paperheight=297 mm,left=0mm,right=0mm,top=0mm,bottom=0mm]{geometry}
        \usepackage{eso-pic} 
        \usepackage{tikz}
        \usepackage{ocgx2}
    \usepackage{scrextend}

\begin{document} \ClearShipoutPicture \AddToShipoutPicture{% \AtPageLowerLeft{% \begin{ocg}[printocg=never]{holes}{holes}{1} \begin{tikzpicture}%[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm] \clip(0,0) rectangle (21,29.7); \draw [fill=black!10!] (1.2,10.85) circle (3mm); \draw [fill=black!10!] (1.2,18.85) circle (3mm); \end{tikzpicture} \end{ocg} } }

some text

\vspace*{10cm}

some times i need this part

\vspace*{2cm}

\begin{addmargin}[2cm]{2cm} some times i add margins \end{addmargin} \end{document}

Caveat: You probably need to use Adobe Acrobat to print, since almost no other PDF viewer understands OCGs

You can switch the layers on enter image description here

and off

enter image description here

DG'
  • 21,727
  • Besides Acrobat (Reader), the Chromium/Chrome built-in PDF viewer acknowledges OCG settings for printing and viewing. – AlexG Feb 10 '21 at 11:48
  • @AlexG – Good to know! – DG' Feb 10 '21 at 11:49
  • 1
    Thanks DG, it works that way! But if there is a tex-editor version for this, I would welcome it. Also thanks to AlexG! Because Im using Chrome a lot, this way is the best for me with OCG. As soon as I open the PDF and print it, it hides the holes automatically. Thanks a lot to both of you! – Bilal Yilmaz Feb 10 '21 at 14:02