4:41 AM
Suppose you are writing with a \item inside an enumerate. You need to attach a graph to the center. What would you do: attach the file inside enumerate or outside of it? In other words, would you center the graph with respect to item margins or with paper margins?

@manooooh \begin{enumerate} \item $\vcenter{\hbox{\includegraphics{example-image-duck}}}$ \end{enumerate}.

@marmot what is the role of vcenter? P.S. I would center the image with respect of \item
Is \vcenter the same as \begin{center}? Because I do that: use \begin{center} inside an \item

@manooooh No \vcenter centers vertically.
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{enumerate}
\item $\vcenter{\hbox{\includegraphics{example-image-duck}}}$
\end{enumerate}
\end{document}

@marmot oh! Sorry, I mean "center horizontally", but we can discuss if an image has to be centered wrt the page or an environment that contains the image too

@manooooh
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{enumerate}
\item \hfill$\vcenter{\hbox{\includegraphics{example-image-duck}}}$\hfill\mbox{}
\end{enumerate}
\end{document}

4:51 AM
I mean:

2 hours later…
6:45 AM
@manooooh I would center the graph with respect to the \item margin.

7:01 AM

7:12 AM
@JouleV Why have you deleted your answer here: tex.stackexchange.com/questions/491569/…? It worked and it was quicker than mine!

@CarLaTeX lol

7:33 AM
@UlrikeFischer I've been thinking about l3str-convert. We need the escaping (URL/name/string), but do we really need the actual encoding conversion? I'm wondering if we should just extract the bits we require
@UlrikeFischer I'm also wondering why Bruno made lots of files: at the moment, I'm thinking we want just want one big file
@UlrikeFischer Perhaps one for the team list

7:49 AM
@UlrikeFischer Ah, I see Section 7.9.2.2 of the PDF 1.7 spec covers this to some extent: we need UTF16BE plus PDFDocEncoding

@JosephWright just wanted to write this. Heiko's code has such conversions too.

@UlrikeFischer Bruno hasn't done PDFDocEncoding, so we'll need to sort that
@UlrikeFischer I'm not sure about all the other conversions, but I guess that payload is pretty light
@UlrikeFischer I think we should look to move the conversion code: we really are going to need it. I'll raise on the team list

1 hour later…
9:22 AM
@AlanMunn ooh
@CarLaTeX ooh

9:35 AM
@JosephWright do we need pdfdoc encoding or can you always use utf16 now?

@DavidCarlisle ooh

@marmot high level structured latex markup:-)
@manooooh let latex do what it does, center within the list if it is part of a list or center within the page if it is a float that has floated in to the list

@DavidCarlisle Even Larry Wall would approve. :)

9:51 AM
@DavidCarlisle good question. The reference mentions a need for pdfdocencoding only once for the Status field of FDF-dictionary (form field export) and says there "Because name objects in the appearance dictionary are limited to PDFDocEncoding, they cannot represent non-Latin text.". But probably the larger problem would be to disentangle all the pdfdoc encoding stuff from hyperref. (in pdf 2.0 you can use also utf8 beside utf16be)

10:02 AM
2

10:23 AM
@JosephWright hm. Doesn't work for me. texlua l3build.lua gives "script not found". How does one initialize kpse here?

@UlrikeFischer When you say "PDF 2
Also supports utf-8, does that only refer to FDF or to all strings?

@MarcelKrüger more or less everywhere, where the old reference says "pdfdoc or utf16BE", it says now "pdfdoc or utf16be or utf8". utf8 is identified by the BOM.

@UlrikeFischer identified by not having a utf16 bom or do you have to have a utf8 bom?

10:39 AM
@DavidCarlisle utf16be starts with 254 255 (thorn ydieresis), utf8 with 239 187 191 (dieresis, guillemotright, questiondown).

@UlrikeFischer Oh OK utf8 bom then (Microsoft weirdness takes over the world:-)

@DavidCarlisle well there must be some marker to distinguish from pdfdocencoding, so what else?

@UlrikeFischer yes it's not completely unreasonable

@DavidCarlisle they could naturally drop pdfdocencoding and break all pdf generated with pdftex ;-)

@UlrikeFischer except pdtex hardwires 1.x so is immune to 2.0 changes...

10:44 AM
@DavidCarlisle not with @JosephWright around.

@UlrikeFischer yes well he could fix all the hardwired pdfdocencoding usage at same time

@DavidCarlisle and me all the hard coded pdfdocencoding in hyperref?

@UlrikeFischer good plan (although shouldn't that be the same as forcing the existing unicode option, then deleting dead code?)

@DavidCarlisle probably, and probably a good plan. The pdf would get a bit larger, but the code would be much cleaner without all this variants.

2 hours later…
12:58 PM
@DavidCarlisle Unconventional aims require unconventional coding. ;-)

1:54 PM
@CarLaTeX In my computer, your answer is 7 seconds quicker than mine :) (I think you know that I am the first upvoter of your answer)

2:41 PM
@JouleV I intended that your question was simpler (less code than mine) and is different, so you should undelete it :)

3:00 PM
Hey, I write this code,

\begin{figure}[!htb]
\begin{minipage}{\textwidth}
\minipage{0.5\textwidth}
\fbox{\includegraphics[scale=0.47]{abstraction2.pdf}}
\caption{Abstraction after first refinement}
\endminipage\hfill
\minipage{0.5\textwidth}
\fbox{\includegraphics[scale=0.47]{abstraction2solution.pdf}}
\caption{Solution for refined abstraction}
\endminipage
\end{minipage}
\end{figure}

However the captions do not center align
How do i center align the captions
\centering does not work

@CarLaTeX Okay, I do it as requested :) But both answers use font, so I don't think they are different.

@JouleV but I use it within the matrix options, it works also alone :)

3:18 PM
@r.k always use use \begin{minipage} not \minipage and use \centering within the minipage if you want that. but you may have specified caption formatting elsewhere, best to make a real example and ask a question on site. (unrelated but not allowing the figure on a float page makes it much more likely that it drifts to the end of the document)

@DavidCarlisle I changed it to
\begin{figure}[!htb]
\begin{minipage}{0.5\textwidth}
%\minipage{0.5\textwidth}
\centering
\fbox{\includegraphics[scale=0.47]{abstraction2.pdf}}
\caption{Abstraction after first refinement}
\end{minipage}
%\endminipage\hfill
%\minipage{0.5\textwidth}
\begin{minipage}{0.5\textwidth}
\centering
\fbox{\includegraphics[scale=0.47]{abstraction2solution.pdf}}
\caption{Solution for refined abstraction}
%\endminipage
\end{minipage}
\end{figure}
However it still does not provide centered captions

@r.k as I say, caption formatting may be determined elsewhere (in the class file, by the caption package, in random code in your preamble) make a test document and post as a question on site. By default captions are centred if one line or set as a justified full width paragraph if longer.
you will need a % after the middle \end{minipage} or you have a word space between the minipages, so can not fit two .5\textwidth ones on one line.

@DavidCarlisle yea the one line captions are working fine, and i am getting them as centered

@r.k well since multi-line ones are full width, centering doesn't really mean anything.

ah thanks

3:28 PM
@r.k are you sure you want [!htb] ?

in one place

@DavidCarlisle I do not understand what you mean by "center within the page if it is a float that has floated in to the list"

@manooooh if you have a figure earlier in the document then it may float to the top of a page that contains your enumerated list (since lists can span over page breaks.) or if you have a [ht] float that in this case does not move so stays within the list.

3:53 PM
What a match! 6:0 and counting :)

4:24 PM
@yo' Not so striking, if it's basketball.

@egreg well, ice hockey, 8:0 final score

@yo' That's indeed a sweep out.

@egreg I should (not) speak to my Austrian supervisor :)

1 hour later…
5:55 PM
I'm making a tex.sprint call inside a LuaTeX example file.

and?

The tex.sprint call has a multiline argument surrounded by [[ ]] (which I read is how Lua handles strings). And it compiles ok.
But if I add a comment at the end of one of the lines, it doesn't.
I would have expected that to work.

@FaheemMitha a tex comment or a lua comment?

@DavidCarlisle A TeX comment. Starting with %. Sorry, should have made that clear.
I mean, since it's being passed to TeX, it should behave no differently.

@FaheemMitha in \directlua (where % is a comment) or in a luacode package environment (where it is not)

5:58 PM
This is in a separate Lua file, which is being called by \directlua.
@DavidCarlisle The former.

@FaheemMitha oh so tex never sees it at all, you need lua comments --
@FaheemMitha no not if it is in a separate file

@DavidCarlisle Are you saying that usage of % inside a call to tex.sprint in a Lua file is not seen by TeX?

@FaheemMitha tex doesn't process the lua code at all, nothing special about %

@DavidCarlisle I thought everything in tex.sprint for handed to TeX for processing.
That's what the manual seems to be saying. So wouldn't it handle the comment too?

@FaheemMitha the lua code produces a striing which is inserted into the tex input stream, tex doesn't process the lua source

6:02 PM
@DavidCarlisle Yes, I got that. But the string that is produced is just whatever is inside tex.sprint([[ ]]), isn't it?
I thought it just passed it on to TeX.
The code is quite simple. It is just:
\documentclass{article}
\usepackage{luacode}
\usepackage{filecontents}
\begin{filecontents*}{luamacro.lua}
package.cpath="/usr/lib/x86_64-linux-gnu/lua/5.2/?.so;"..package.cpath
tex.sprint([[\newcommand{\foo}{foo}]])
tex.sprint([[\newcommand{\fee}{fee fi\\ % foo
fo fum}]])
\end{filecontents*}
\directlua{luamacro = require "luamacro.lua"}
\begin{document}
%\foo
\fee
\end{document}

@FaheemMitha as ever you should have provided an example at the start, I'm just now seeing what you mean, I would guess that you are commenting out the whole line (as the inserted tokens are already tokenized)

@DavidCarlisle See above.
Without the % foo it works.
If I switch to -- foo it works. But it would be nice to have a clear idea why.
I could ask a question on the site if you think it is reasonable.

@FaheemMitha the sprint output is essentially always on one line

@DavidCarlisle Oh?

@FaheemMitha just use a Lua comment -- foo

6:07 PM
So it throws away newlines?

@FaheemMitha oh but not inside a [[ string

@DavidCarlisle Pardon?
This is what the manual says:
> Each string argument is treated by TEX as a special kind of input line that makes it suitable for use as a partial line input mechanism:

normally you could comment the lua code with lua comments but you can't have comment inside a string

As usual, I don't quite understand it.
@DavidCarlisle So you are saying -- foo should not work either?

@FaheemMitha no as in most programming languages you can not have a comment inside a literal string.

6:10 PM
@DavidCarlisle In this case, it compiled with the -- foo.
I just tried it.

@FaheemMitha didn't it put --foo into the string?

@DavidCarlisle So it did. My mistake.
So no comments are possible in this case?
And there are no calls which let one put multi-line arguments?

@FaheemMitha well you could use ]] -- foo to stop the string and start the next line .. [[ to concatenate a restarted string if you really want that.

@DavidCarlisle To be clear, multiple sprint calls would be "remembered" by TeX, correct?
It would just continue where the last string left off?

@FaheemMitha yes although the timing is slightly odd, they all come at the end

6:18 PM
@DavidCarlisle I don't follow. "the timing is slightly odd"? "they all come at the end"? What's they? The lines? And at the end of what?

@FaheemMitha any tex tokens generated are inserted at the end of the \directlua normally this isn't an issue but if they make make definitions then you inspect the tex state in the Lua, then this can show up

@DavidCarlisle I'm not sure what the issue is. You're saying that TeX processes everything at the end of the call to \directlua?
Does that mean there can be problems with making a definition and then using it in the same Lua file? Because I did it earlier, and it worked.
And it's still the case that something like:
tex.sprint([[\newcommand{\foo}{foo}%]])
As a separate line in the Lua file works as expected. As long as one puts it at the end?
Or more explicitly:
tex.sprint([[\newcommand{\foo}{foo}% some comment]])

1 hour later…
7:37 PM
@DavidCarlisle, @UlrikeFischer On the PDF encoding business, don't we need PDFDocEncoding as UTF-16BE means that everything is encoded, including ASCII text?

@JosephWright well it does, although if utf8 becomes feasible that would be avoided to an extent, but i know from hyperref that it isn't great it sort of works Ok for western europe if you are covered by pdfdocencoding but hard to know up front if you are going to need unicode option and switch to utf16. encoding ascii as utf16 isn't very hard:-)

@DavidCarlisle Well ....
\RequirePackage{l3str-convert}
\ExplSyntaxOn
\str_set_convert:Nnnn \l_tmpa_str { Oh!~How~I~wish~you~would~say~you~could~C. }
{ } { utf16be/name }
\str_show:N \l_tmpa_str
\l_tmpa_str=#00O#00h#00!#00#20#00H#00o#00w#00#20#00I#00#20#00w#00i#00s#00h#00#2
0#00y#00o#00u#00#20#00w#00o#00u#00l#00d#00#20#00s#00a#00y#00#20#00y#00o#00u#00#
20#00c#00o#00u#00l#00d#00#20#00C#00..

@JosephWright ah yes well I meant encoding ascii as utf16 isn't hard (just insert a null byte every other byte) I wasn't thinking about the hex encoding:-)

@DavidCarlisle My point was that the raw data is (a) much bigger and (b) unreadable in the raw PDF

@JosephWright but I am confused actually why the #00 encoding? the text shouldn't be much bigger it should be twice as big which is same argument against using utf-8 for european accented letters but consistency wins over disk space in most arguments

7:47 PM
@DavidCarlisle Perhaps it's worth doing, though, as it is a lot easier, and all we then need is a simply UTF-8/16 switch
@DavidCarlisle I picked the one suitable for PDF names ... the string one would have \000 (and that checks out versus hyperref, other than it seems to currently miss the BOM ... one for Bruno)
@DavidCarlisle Yes, I see that: I think on balance we should just integrate at least enough of l3str-convert to handle this, then just use a fixed conversion

@JosephWright it's probably easiest not to add the BOM in the conversion functions, as that makes concatenating strings easier, you can just insert a boM at the point you add a string that needs one.

@DavidCarlisle Yeah, maybe: I'm not sure what Bruno's design is here
@DavidCarlisle Anyone, probably for the team list ...
@DavidCarlisle What I'm less sure of is whether just to strip Bruno's code down to the core idea: UTF-8 to UTF-16 (and perhaps UTF-32), plus the escape code, but perhaps not all the 8-bit stuff
@DavidCarlisle Also wonder why Bruno went for lots of files for the conversion stuff, rather than just loading it all in one big file

8:19 PM
@JosephWright luatex encodes most things in utf16 anyway, so I don't think that it is a real problem. But there a some details that are a bit unclear. E.g. hyperref insists to write bookmarks in octal notation, and for xetex is converts to utf8 because xdvipdfmx converts (or did convert) then to utf16 again.

9:16 PM
Is there any way to get \text.sprint to strip trailing spaces? The manual says it doesn't. Which can occasionally be a problem.

@FaheemMitha you can use gsub to do a lua string replace before printing it

9:45 PM
@DavidCarlisle I have a question regarding 'protocol' on TeX-SE: In your answer to my question regarding apparent recursion in an edef statement you pointed out several things in my code I should do differently (and I thank you for that), but should I incorporate those corrections into my original MWE or should I enter my own answer and include them there, or just leave it be?

@DavidCarlisle Ok, thank you. I'll take a look.

10:08 PM
@OneMug I think it's best to leave it be. Generally adding an answer of your own which simply repeats (with slight changes) an existing answer is discouraged, and editing your question to reflect the answer changes the question and removes the context of the answer(s).

10:27 PM
@OneMug leave it be really, comments in comment are more or less personal tips but question/answer are best focussed on a single issue. That said if I'm posting an answer myself i usually try to fix unrelated things because I know people just copy paste code from answers and would pick up unrelated bad habits (so as a general rule code in questions is not intended to be good, but code in answers should be, as far as possible)

11:17 PM
@DavidCarlisle and @AlanMunn: Thanks for the reply, leave as is (kinda thought so).
Need some help for the title of my next query though. The parsing routine that was the driver for the problem edef statement in my last question could be fed input containing paragraphs and/or groups (braces). My existing routine chokes on paragraphs (I have not defined them long which I've have never used before) and saves only the first character in an embedded group. Any advice on how I would break that down into actual questions?

11:31 PM
@CarLaTeX
Am I missing something, that I should have read ? since I don't see my comment to CarLaTeX did it go direct? or was it aborted ? ok now I see this

11:52 PM
@CarLaTeX Whilst playing with \standalone I found this worked native to windows and wanted to check it does not impact you
\documentclass{standalone}
\usepackage{tikzlings} % required for both the inputs
\usepackage{tikzducks} % required for just the carlatex input
\usepackage{standalone}
\begin{document}
\write18{curl -B https://raw.githubusercontent.com/samcarter/tikzlings/master/Examples/marmot.tex>marmot.tex}
%\message{hello}
\input{carlatex} \scalebox{2}{\input{marmot} Hats off to you M'am}