LibreMonk

joined 10 months ago
[–] LibreMonk@linkage.ds8.zone 1 points 1 day ago* (last edited 1 day ago)

One annoying limitation is that the last page and a penultimate page cannot have different behavior in the picturecommand option. I thought I was fucked for ½ a day. But hacked around that by using the pagecommand and nesting \ifthenelse{\AM@page = (penultimate page №)}{\begin{picture}(0,0)\put(50,-50){…}… inside the pagecommand. Makes me wonder what’s the point of having the picturecommand. There is a picturecommand* which only executes on the 1st page, and apparently no equivalent for pagecommand -- but we can test the internal variable anyway.

 

Suppose you feed a multi-page PDF into \includepdf. If you only want pagecommand or picturecommand to take effect on some pages, you normally must split the construct up into multiple invocations. E.g.

\includepdf[pages=1], pagecommand={\doStuffOnPageOne}]{file.pdf}
\includepdf[pages=2-], pagecommand={\doStuffOnPagesAfterOne}]{file.pdf}

It gets ugly fast when there are some commands you want performed on every page, and some on select pages, because then you must write and maintain redundant code.

Fuck that. So here’s a demonstration of how to write code inside pagecommand and picturecommand that is page-specific:

\documentclass{article}

% Demonstrates use of the pdfpages package with page-by-page actions that are specific to select pages.

\usepackage{mwe}        % furnishes example-image-a4-numbered.pdf
\usepackage{pdfpages}
\usepackage{pdfcomment}
\usepackage{ocgx2}      % furnishes the ocg environment (PDF layers, but not really needed for this demo)
\usepackage{fancybox}   % furnishes oval box
\usepackage{fontawesome} % furnishes \faWarning

\begin{document}

\makeatletter
\includepdf[pages=1-,pagecommand={%
  % \makeatletter ← ⚠ does not work in this scope; must wrap the whole includepdf construct
  \pdfcomment[icon=Note, hoffset=0.5\textwidth, voffset=5em]{%
    (inside pagecommand, executing on every page)\textLF\textLF
    \texttt{\textbackslash AM@page} variable: \AM@page\textLF\textLF
    Side-note: the voffset option has no effect when the value is positive (5em in this case)% 
  }%
  \ifthenelse{\AM@page = 1 \OR \AM@page = 2 \OR \AM@page = 12}{%
    \pdfcomment[icon=Insert, hoffset=0.5\textwidth, voffset=-6em]{%
      (inside pagecommand, affecting only pages 1, 2, and 12)\textLF\textLF
      \texttt{\textbackslash AM@page} variable: \AM@page\textLF\textLF
      Strangely, the voffset option only works if it is negative.% 
    }%
  }{}
  % \makeatother
}, picturecommand={%
  \put(50,715){Inside the picture environment:}
  \put(50,700){%
    \begin{tabular}[t]{llp{0.6\textwidth}}
      internal \texttt{\textbackslash @tempcnta}    variable (useless):     &\the\@tempcnta&\\
      internal \texttt{\textbackslash @tempcntb}    variable (useless):     &\the\@tempcntb&\\
      internal \texttt{\textbackslash AM@pagecnt}   variable (useless):     &\the\AM@pagecnt&\\
      internal \texttt{\textbackslash AM@abs@page}  variable (useless):     &\AM@abs@page&\\
      internal \texttt{\textbackslash AM@page}      variable (interesting): &\AM@page & \faWarning Inside picturecommand, this number is 1 higher than the actual page number! But it’s correct inside pagecommand (see the annotation note to check).\\
      internal \texttt{\textbackslash AM@pagecount} variable (interesting): &\AM@pagecount&\\%
    \end{tabular}
    % lastpage: \AM@lastpage% broken
    \ifAM@firstpage
    We might expect this to trigger on the 1st page, but it never does. Likely because the page counter is incremented before picturecommand is invoked. It would perhaps work in the pagecommand construct.
    \fi
  }
  \put(500,770){% The ocg environment is irrelevant and unnecessary.. just here to demo PDF layers.
    \begin{ocg}{section labels}{sl1}{on}\color{blue}
      \Large\rotatebox{-45}{\setlength{\fboxsep}{6pt}\Ovalbox{Section~A}}
    \end{ocg}}}]%
{example-image-a4-numbered.pdf}
\makeatother
\end{document}
 

It would sometimes be useful to write conditional code that depends on boolean values defined in a parent package. E.g. the \pdfcomment package has the boolean “final”, which disables all PDF annotations in the document (\usepackage[final]{pdfcomment}). There is some other logic in my document that should also be disabled when that boolean is true. I tried simply using:

\ifpc@gopt@final\else%
…code that should not run when final is true…
\fi

pdflatex gives: “Undefined control sequence”

More generally, many draft options are often useful for controlling logic within the document for which a parent uses a draft option. Also when defining a custom letterhead in the scrlttr2 class there are booleans for many items that may or may not be wanted in the letterhead.

Has anyone managed to read a parent boolean?

(update) This thread gives useful options for many situations. But it does not completely answer the question because there are non-draft related booleans.

SOLVED

The \ifpc@gopt@final is reachable but only inside a \makeatletter stanza. Thus:

\makeatletter
\ifpc@gopt@final\else%
…code that should not run when final is true…
\fi
\makeatother
[–] LibreMonk@linkage.ds8.zone 1 points 1 week ago* (last edited 1 week ago)

Someone tells me “look into \scantokens instead of rewriting to a file”. After a brief look, I have to say: No. Fucking. Way. That looks like a rabbit hole that leads to the center of the planet. No thanks.. I don’t need to spend weeks more on this digging through (what looks like) the most raw low-level code that makes assembly languages look like tinker toys.

Low level TeX code really seems like a strange beast. Something you should learn in your early teens while the brain is still highly plastic. I wish I learnt it because I would better understand all the bizarre and obscure glitches I run into with LaTeX. But I think I might be past the point where benefit outweighs the pain.

 

Some might find it useful to import a text file and put the contents into a PDF annotation. E.g. a PDF is in language A and you want to make a translation available in language B, in a PDF annotation.

Here’s how:

\documentclass{article}

\usepackage{mwe}
\usepackage{pdfpages}
\usepackage{pdfcomment}
\usepackage{newfile}
\usepackage{xstring}
\usepackage{catchfile}

% heredoc holding text that normally breaks the \pdfcomment command:
\begin{filecontents*}{\jobname_sample.txt}
line one

line two
tricky symbols: _&%
\end{filecontents*}

% normally the above file is whatever you supply to be imported into the PDF annotation. The heredoc is just to provide a self-contained sample.

% Create \pdfcommentfile, which is a version of \pdfcomment that can read from a file:
\makeatletter
\gdef\pdfcommentfile#1{%
  \begingroup
  \everyeof{\noexpand}%
  \long\edef\temp{\noexpand\pdfcomment{\@@input{#1}}}%
  \temp
  \endgroup
}%
\makeatother

\CatchFileDef{\cfile}{\jobname_sample.txt}{} % side-effects: replaces blank lines with “\par” and drops percent symbols

% Replace blank lines with \textLF and replace special symbols with those that are safe for \pdfcomment. Warning: this is probably not a complete list of all constructs that break \pdfcomment!
\StrSubstitute{\cfile}{\par}{\string\noexpand\string\textLF\ }[\pdfannotationtxt] % the hard space is after textLF is a bit unfortunate; not sure how to do a normal space there
\StrSubstitute{\pdfannotationtxt}{\%}{\string\noexpand\string\%}[\pdfannotationtxt]
\StrSubstitute{\pdfannotationtxt}{_}{\string\noexpand\string\_}[\pdfannotationtxt]
\StrSubstitute{\pdfannotationtxt}{&}{\string\noexpand\string\&}[\pdfannotationtxt]

% the \pdfcomment command cannot directly handle the above substitutions (nor can it handle the original unsubstituted version). So we write the new version to another file:

\newoutputstream{filteredresult}
\openoutputfile{\jobname_filtered.txt}{filteredresult}
\addtostream{filteredresult}{\pdfannotationtxt}
\closeoutputstream{filteredresult}

\begin{document}
\pdfcommentfile{\jobname_filtered.txt}
\includepdf{example-image-a.pdf}
\end{document}

There should be a way to substitute the special characters and blank lines then feed it directly to \pdfcomment, but I’ve exhausted that effort. I’ve been in this LaTeX rabbit hole for days now trying to do something that should be simple. So this is as far as I go. The code above works but it’s ugly as fuck that we have to write the filtered text to file then read the file back in. The file i/o slows down compilation much more than what I consider reasonable.

 

cross-posted from: https://linkage.ds8.zone/post/363360

I am trying to do some simple character replacements on an input file and writing it to a file. The output produced by \StrSubstitute is quite bizarre. Here is a MWE:

\documentclass{article}

\usepackage{newfile}      % furnishes \newoutputstream
\usepackage{catchfile}    % furnishes \CatchFileDef
\usepackage{xstring}      % furnishes \StrSubstitute
\usepackage{stringstrings}% furnishes \convertword (a \StrSubstitute alternative)

% heredoc that creates source input file
\begin{filecontents*}{\jobname_sample.txt}
line one

line two
tricky symbols: _&%
\end{filecontents*}

\CatchFileDef{\cfile}{\jobname_sample.txt}{}

\begin{document}

% Replacements needed:
%   & → \&
%   % → \%
%   _ → \_
%   \newline\newline → \textLF (replace blank lines)
%
\StrSubstitute{\cfile}{&}{\&}[\mystring]
\StrSubstitute{\mystring}{\%}{\%}[\mystring]
\StrSubstitute{\mystring}{_}{\_}[\mystring]
\StrSubstitute{\mystring}{\newline\newline}{\\textLF}[\mystring]

\newwrite\myoutput
\immediate\openout\myoutput=\jobname_filtered_native.txt
\immediate\write\myoutput{\mystring}
\immediate\closeout\myoutput

\newoutputstream{filtered}
\openoutputfile{\jobname_filtered_newfile.txt}{filtered}
\addtostream{filtered}{\mystring}
\closeoutputstream{filtered}

\noindent\textbf{filtered catchfile}:\\
\mystring

\noindent\textbf{filtered catchfile (2nd attempt)}:\\
\convertword{\mystring}{\newline\newline}{\noexpand\textLF}
 
\end{document}

That uses two different techniques to write to a file, and both give slightly different yet wildly unexpected output:

$ cat sample_code_filtered_native.txt
line one \par line two tricky symbols: \protect \global \let \OT1\textunderscore \unhbox \voidb@x \kern .06em\vbox {\hrule width.3em}\OT1\textunderscore \&
$ cat sample_code_filtered_newfile.txt
line one \par line two tricky symbols: \global\let \OT1\textunderscore \unhbox \voidb@x \kern .06em\vbox {\hrule width.3em}\OT1\textunderscore \&

What triggered all that garbage to be created? This is what the output [b]should[/b] be:

line one\textLF
line two
tricky symbols: _&%

I also tried a 3rd way to write \mystring to a file, as follows:

\begin{filecontents*}{\jobname_myvar.txt}
  \mystring
\end{filecontents*}

That approach literally writes the string “\mystring” to a file, which is useless in this case.

(update) apparently a \string needs to prefix the substituted strings.

[–] LibreMonk@linkage.ds8.zone 2 points 3 weeks ago

Thanks for the tip. It seems to work but I have to say it’s a rough UX because the UI is really meant for a graphical browser. I could not even paste my UID and PW in to login.

[–] LibreMonk@linkage.ds8.zone 2 points 3 weeks ago

For the same reason, I suppose you would love text adventure games like Hitchhiker’s Guide to the Galaxy, where you have to come up with your action, as opposed to getting visual aids which come like a loaded question, steering you and somewhat robbing you of control.

[–] LibreMonk@linkage.ds8.zone 2 points 3 weeks ago* (last edited 3 weeks ago) (2 children)

indeed.. #NeonModemOverdrive failed for me too.

So, how did you do post to lemmy.ml? Did you use cURL? If so, I would love to see the sample code.

[–] LibreMonk@linkage.ds8.zone 0 points 3 weeks ago* (last edited 3 weeks ago) (1 children)

It is exactly that.

There are ~95 pages of rights and obligations covered in EU Directive 2015/2366, as well as EC Regulation 593/2008. Have you read them, or anything else to substantiate your claim?

You’re trying to solve the wrong problem.

There is no such thing as a “wrong problem”.

You do you. This thread is not about your problems. Start your own thread if you want a different problem worked. In this thread, you can either help solve the problem at hand, or fuck off.

[–] LibreMonk@linkage.ds8.zone 2 points 3 weeks ago

There was a story about a German guy insisting on paying his radio licensing fees in cash. He setup an escrow account and paid his invoices into that, so that the state could not claim he was just using cash refusal as an excuse not to pay. I don’t think I ever heard what came of the legal case.

[–] LibreMonk@linkage.ds8.zone 2 points 3 weeks ago* (last edited 3 weeks ago) (1 children)

I heard postbank was eliminated in Germany but post office banking is still an option in other countries. I doubt any post office banks stand on their own. The one I’m aware of is just a proxy for another crappy bank.

Many elderly people can’t use a smartphone so smartphone only options definitely sound like a no go.

It’s somewhat convenient that tech illiterates are in the same boat with the streetwise (who are tech saavy enough to distrust commercial tech that’s being pushed down our throats). But there are efforts to divide us. Elderly folks are getting social helpers with tech, which will shrink those resisting enshitification of everything to a population that’s easier to marginalise. I also don’t suppose it will be long before the tech illiterate elderly are no longer with us anyway.

[–] LibreMonk@linkage.ds8.zone 2 points 3 weeks ago (2 children)

at least in Germany companies and state are not anymore required to accept cash for invoices

Yikes. That’s a shame. There is the EC Recommendation of 22 March 2010 (2010/191/EU) which wisely states:

A debtor can discharge himself from a payment obligation by tendering euro banknotes and coins to the creditor.

I am surprised Germany has gone against that. I thought cash was loved by Germans.

[–] LibreMonk@linkage.ds8.zone 5 points 3 weeks ago* (last edited 3 weeks ago)

Glad to hear you’re standing up for yourself, and others. And glad to hear an analog option is still possible. That’s by far the most important option. If you can do everything offline, then you can escape whatever garbage tech they try to push. Essential services like banking and utilities should always have an offline analog option.

[–] LibreMonk@linkage.ds8.zone 1 points 3 weeks ago* (last edited 3 weeks ago) (3 children)

The thesis is: what are our rights? Knowing your rights is a good idea /before/ you go off and try to solve a problem.

It may very well be that we have no useful rights and the choices are: be bullied, or find a different bully. But let’s not get ahead of ourselves. Other banks are garbage too, so it may be better to improve the bank you have (if possible through legal actions and exercising your rights) then to make it someone else’s problem.

[–] LibreMonk@linkage.ds8.zone 1 points 3 weeks ago* (last edited 3 weeks ago)

you should probably just keep the money in cash

Of course. Cash would solve the problem. But creditors are refusing that now and also refusing cards at the same time. Otherwise the bank card could get cash out of the ATM and pay the creditors.

 

Suppose you resist a bank that forces you to access your account exclusively via some shitty phone app, which also requires you to buy a new smartphone. And suppose you refuse, so your only access to the bank account is via the card.

What happens when the time comes that (e.g.) the gov or a creditor demands a payment by credit transfer, not by card? Are you consequently forced by your obligation to make a payment to then buy a phone? Or do you have a right to manually order a payment from your bank by sending a written letter or something?

There is this law but I’m not sure it’s applicable:

REGULATION (EU) No 260/2012, Art.4: Interoperability

3. The processing of credit transfers and direct debits shall not be hindered by technical obstacles.

I think that law was really intended for the bank-to-bank segment of the transaction, not consumer to bank. I get the impression we have no codefied rights, just recommendations to lawmakers, such as:

The European Commission, in its 2012 Green Paper, insisted that standardisation in the mobile payments area should ensure full interoperability between mobile payment solutions, and favour open standards to ensure the mobility of consumers when they wish to change their telecom operator or bank.

In its Mobile Payments Initiatives Overview, the European Payments Council stated that different mobile payment solutions from multiple payment service providers should be able to coexist in the same mobile device. In its opinion, consumers should not be bound to a specific network operator or particular mobile equipment, but should be able to switch between payment service providers, with interoperability as a key feature needed to achieve these goals.

But to be fair that was written 10 years ago. Any headway?

 

cross-posted from: https://linkage.ds8.zone/post/341870

I signed an agreement with a creditor that obligates me to pay them using a bank inside the country. This was fine initially but then I moved out of the country and the acct was closed. Other banks will not open an account for me and the creditor refuses cash. So the creditor is treating me like a non-payer to a quite harsh extent.

I have over-simplified here but I just want to know very generally what the common practices are around the world for contract law situations where someone without much bargaining power signs a contract that obligates them to do something that’s only achievable if other 3rd-parties agree to serve them, and then those other 3rd-parties later refuse.

BTW, I am not interested in advice on situational hacks and angles like “find a friend to pay for you”. I want to know how courts treat the situation when all options have failed. Are people typically held accountable for agreeing to something which relied on actions of others?

(the situation is not in the Netherlands but I am still interested in answers as to how these kinds of situations are dealt with in the Netherlands)

/cc @law@a.gup.pe

 

cross-posted from: https://linkage.ds8.zone/post/341870

I signed an agreement with a creditor that obligates me to pay them using a bank inside the country. This was fine initially but then I moved out of the country and the acct was closed. Other banks will not open an account for me and the creditor refuses cash. So the creditor is treating me like a non-payer to a quite harsh extent.

I have over-simplified here but I just want to know very generally what the common practices are around the world for contract law situations where someone without much bargaining power signs a contract that obligates them to do something that’s only achievable if other 3rd-parties agree to serve them, and then those other 3rd-parties later refuse.

BTW, I am not interested in advice on situational hacks and angles like “find a friend to pay for you”. I want to know how courts treat the situation when all options have failed. Are people typically held accountable for agreeing to something which relied on actions of others?

(the situation is not in the UK but I am still interested in answers as to how these kinds of situations are dealt with in the UK)

 

I was thinking about the problem with JavaScript and the misery it brings to people. I think I’ve pinned it down to a conflict of interest.

Software is supposed to serve the user who runs it. That’s the expectation, and rightfully so. It’s not supposed to serve anyone else. Free software is true to this principle, loosely under the FSF “freedom 0” principle.

Non-free software is problematic because the user cannot see the code. The code only has to pretend to serve the user while in reality it serves the real master (the corporation who profits from it).

JavaScript has a similar conflict of interest. It’s distributed by the same entity who operates API services -- a stakeholder. Regardless of whether the JS is free software or not, there is an inherent conflict of interest whereby the JS is produced by a non-user party to the digital transactions. This means the software is not working for the user. It’s only pretending to.

 

I just started using the LaTeX community (!tex@lemmy.sdfeu.org). Sad to see it go.

update


Just noticed it’s back up, but there are no communities. That’s bizarre. So if someone not on lemmy.sdfeu.org were to post to !tex@lemmy.sdfeu.org, I guess it’d still be like a ghost node because the post would have nowhere to go on the hosting node.

view more: next ›