Categories
Editing IT LaTeX Productivity

How to Create a Kindle Ebook with LaTeX

The ebook is now available! Head over to Amazon to get a copy. 

Book publishing is easier than ever, and my favorite language to use to create books is LaTeX. The Amazon ebook upload platform (https://kdp.amazon.com) allows users to upload a variety of formats, but not for LaTeX or its product, a PDF. Why is that? The reason is that Kindle ebook viewers are not simple PDF viewers. Kindle takes the text and reformats it in a way so that it is easily readable and provides the customer a repeatable experience across a variety of books. PDFs, on the other hand, are fixed: no matter what viewer you use, page 37 of a particular book always looks the same.

How then can we use LaTeX to get a Kindle ebook published?

Instead of PDFs, the workflow will rely on HTMLs that are converted to MOBI files. The MOBI files can be imported by Kindle. The big advantage of this workflow is that you can use the HTML files to convert into other formats, such as posting on your blog (which typically requires the removal of all the LaTeX code and a reformatting).

But no worries, we will go through the workflow step by step. I first wanted to give you the big picture.

So, how do we create the HTML file? I am a fan of “one-click” solutions. Whatever we do, LaTeX should generate the final HTML file and we should not have to make any manual changes. This requires some work, but in the end, it is worth it!

For my setup, I am using Overleaf. It offers an online editor, a PDF preview, an automatic Git backup, and a LaTeX compiler on one single website. If you are using a different LaTeX website or your own local installation, a different configuration might be necessary.

Converting LaTeX to HTML

To convert LaTeX to HTML, we need a special compiler, TEX4HT. Unfortunately, TEX4HT only works with pdfLaTeX, not with XeLaTeX or LuaLaTeX. So, as an initial preparation of your existing LaTeX code, you might have to make it compatible to pdfLaTeX. If it is already compatible or if you are already working with pdfLaTeX, you can move on to the next paragraph. If not, you will need to: switch to pdfLaTeX in the project settings; add the ifxetex package; and surround XeLaTeX-specific code with a “\ifxetex … \fi” construction. Having this compatibility allows you to generate PDFs with XeLaTeX, and also produce HTMLs with pdfLaTeX when you switch the compiler settings.

TEX4HT itself needs no installation, as it is already part of the Overleaf setup. All you need to do is include it in your workflow. In Overleaf, this is done by adding a file named “latexmkrc” in the main directory of your project and adding a configuration file (you can find an example here).

First, let’s create the latexmkrc file in the main directory of your project:

$pdflatex = “htlatex %S \”my.cfg,MyFonts,NoFonts\” \”\” \”\” -shell-escape > output.txt; pdflatex -synctex=1 %O %S”;

All this does is override the way Overleaf names the compiler $pdflatex, calling it htlatex in addition to pdflatex, and writing the output of the compilation of htlatex to a new file called output.txt. It also references my.cfg, where much of the HTML configuration resides.

When the compilation has finished, the HTML file will not show up within Overleaf. Instead, you have to actually download the output files (use the drop-down menu at the bottom left in the project window). In the downloaded zip archive, you should check the output.txt for errors. If there are no errors, the HTML file should be in the same directory, ready for use! You can unzip the file, open it in a browser, and there is your ebook! On to step two!

Converting HTML to MOBI

The main tool we will be using (besides LaTeX) is the Kindle Previewer. To preview how your HTML will look on various Kindle devices, download the Kindle Previewer here. Besides previewing, it also converts the HTML to MOBI, which can be uploaded to the KDP website or to a Kindle. Generally, for a professional ebook release, it is recommended to get a set of Kindle devices for testing. With the Kindle uploader tool, you can easily send your MOBI files to a specific device.

Now, open the HTML file with the Kindle previewer. It might give you helpful compiler warnings for you to fix, as well as a conversion to MOBI. Once all is in order, you can browse through your ebook with different Kindle device simulators and, finally, upload the MOBI file to KDP.

But wait! It does not look right!

Now we have to go a little deeper. First, you may wish to review the design documentation by Amazon.

During the conversion, we lost page breaks, maybe some lines, spacing formatting, indentation, etc. The bad news is that there is no 1:1 conversion possible. The good news is that we can include our own .css file to correct a few issues and redefine some of the environments in LaTeX itself to make things right. I will talk about this in a later article. Here, I will talk only about a few instances I have encountered. For others, that is up to you, especially if you used custom formatting in your LaTeX document.

For example, the title sizes might need some fixing:

h2 {
    font-size: 1.5em;
    margin-top: 0.83em;
    margin-bottom: 0.83em;
    font-weight: bold;
}

h3 {
    font-size: 1.17em;
    margin-top: 1em;
    margin-bottom: 1em;
    font-weight: bold;
}

h4 {
    margin-top: 1.33em;
    margin-bottom: 1.33em;
    font-weight: bold;
}

h5 {
    font-size: 0.83em;
    margin-top: 1.67em;
    margin-bottom: 1.67em;
    font-weight: bold;
}

And—kind of a hack—if you dislike paragraph indents, this is the way to go for Kindle:

p {
    margin-top: 1em;
    margin-bottom: 1em;
    text-indent: 0.01em;
}

In LaTeX itself, you might also want to redefine some commands. The following will move your footnotes to the end of the ebook (if you don’t, they will be put into external html files which are not included in the ebook), add a new command “myrule” for horizontal lines, a new command “emdash” for em-dashes, fix semi-colons, and rewrite newpage to tell Kindle to insert a page break.

\ifxetex

\else
    \usepackage{endnotes}
    \let\footcite\citep
    \ifx\HCode\undefined 
        \def\myrule{\hrule}
        \newcommand{\emdash}[1][]{\hspace{0pt}---\hspace{0pt}}%

\else
        \def\myrule{\HCode{<hr style="clear: both" />}}
            \def\semicolon{\detokenize{;}}
            \def\emdash{\HCode{&\#8212;}}% 
            \renewcommand\newpage[1][]{\HCode{<mbp:pagebreak />}}
    \fi
    \let\footnote=\endnote
\fi

That is all for now, I will add a second part with more details (like the table of contents, additional design options, and the index) later. But with some luck, I hope you get your ebook working with these instructions! Feel free to ask questions in the comment section.

Categories
Productivity Wordpress

How to Transform Your Laptop or Tablet into a High-Speed Machine

When mobility is the most important factor

Until now, the choice between laptops and tablets was a choice between mobility and speed. Today, cloud computing has changed everything. In this article, I will offer a quick how-to guide for transforming your existing mobile device into a powerful computer.

What is cloud computing and how has it changed everything? Traditionally, running your own server or website meant that it scaled badly. You could not easily add another server for a busy season and then remove it once it was no longer needed. Cloud computing has closed that gap; now you can add or remove servers whenever you need to do so, and you pay only for what you use.

Cloud computing lets you expand your workspace. Before cloud computing, every few years, you had to replace your device, add a new hard-disk, or deal with various hardware issues. Powerful machines also meant noise — -or additional work or money for cooling.

Today, remote desktop software tools, as well as speedy data centers around the world, allow us to make the most of state-of-the-art mobility. The central idea is to use a remote desktop and lease a cloud server at Amazon.

For this DIY, you will need the following things:

  • A tablet, ideally with the following properties:
  • High resolution
  • Android OS or iOS
  • WiFi or even better, WiFi and LTE for maximum performance
  • A Bluetooth keyboard and mouse (for a full laptop experience)
  • A high-speed Internet connection

Myself, I am using a Sony Z4 Tablet LTE (Amazon.COM http://amzn.to/2jVvvKy, Amazon.DE http://amzn.to/2kRLXPN), but any tablet (even an older one) will work (e.g., Samsung Galaxy Tab S 4G LTE: Amazon.COM http://amzn.to/2khsAww, Amazon.DE http://amzn.to/2krdIy5). For my Internet connection, I am using German Telekom LTE 10GB, and public WiFi spots (using a VPN). In addition, you might want to look for a fast loader by Sony and a good loading cable.

Now, to the DIY part!

First, install “Microsoft Remote Desktop” on your device:

https://play.google.com/store/apps/details?id=com.microsoft.rdc.android

( https://itunes.apple.com/us/app/microsoft-remote-desktop/id715768417 for Mac )

Next, go to: https://eu-central-1.console.aws.amazon.com/ec2/v2/home?region=eu-central-1#Instances:sort=instanceId

You might have to log in or sign up. When that is finished, return to the above URL.

The default is Frankfurt, Germany. If you live outside of Germany, you might want to select a different zone. You can do that by clicking at the top right on “Frankfurt” and selecting a nearby data center.

Now, select “Launch Instance.”

Select “Microsoft Windows Server 2016 Base” and leave the default (t2.micro). You can select faster servers — -if you are willing to pay extra.

Myself, I am using t2.medium, which is enough for most office work and graphic editing and it costs around $40 per month, depending on how many hours you use it (sometimes, I forget to shut it down).

Now click “Review and Launch” and then “Launch.”

At this point, you have to set up a secret key which you will save on your hard disk. You will need it later to decrypt the password. Select “Create a new Key Pair,” give it a name, check the box, and then “Download Key Pair,” and finally “Launch Instance.”

Let’s head back to the instance overview ( https://eu-central-1.console.aws.amazon.com/ec2/v2/home?region=eu-central-1#Instances:sort=instanceId or another, depending on your location). In the list, you should see an entry with the chosen instance type. Once that is green, you can proceed.

Now, click on “Actions” and then “Get Windows Password.” Here, click on “Key Pair Path,” select the previously downloaded key, and press “Decrypt Password.” Copy that password to a safe place, ideally to a password manager like KeePass (http://www.keepass.info).

Finally, click on “Actions” and “Connect.” Download the Remote Desktop file and then open it (directly, or by clicking on the downloaded .pem file in your file browser). The previously installed remote desktop should show up, asking you if you want to connect (check the box, and confirm). In the final screen, you will be asked for a password. Paste the password you have previously copied or saved in your password manager.

You are ready to go!

You know have the mobility of a tablet, the Internet speed of a data center, the scalability of a server, no noise, and no administration work (except configuring your OS) at a fraction of the cost of a similar machine.

There are monthly costs involved if you want a faster server, and the device will need a permanent connection to the Internet. Also, there is a small latency that you usually don’t have when running software on your own machine. This means that videos have a lag between picture and sound (but you could run Youtube in the background while working — that’s usually not possible on a normal Android device.). For Internet browsing, it’s ideal. It might even be faster than browsing in your tablet’s browser, given that only the final picture needs to be transmitted.

Because of this flexibility, I switched to a remote desktop system six months ago and I have not looked back. I have my whole computer system in my light-weight tablet.

A few additional points:

  • It’s best to share your tablet’s storage directly with the remote desktop. To do that, we first have to end the session:
  • Click on the three bars at the top, then cancel the session on the left side.
  • You are now on the main screen of the remote desktop. Click on the three dots of your session, then press “Edit.”
  • Finally, click on “Show additional options” and then select “Redirect local storage.”
  • Click “Save” and then click on your session and your remote desktop should have access to your tablet’s data.
  • You might want to download a browser like Firefox or Chrome. The standard setting of Internet Explorer on the server is very restrictive, so either enable downloads there or download the installation file on your tablet and access it via the local storage.
  • Regularly check Amazon’s billing statement (https://console.aws.amazon.com/billing/home) to check if you are over the free limit.
  • If you are using your mobile plan, be aware of your limits. Depending on your use, you can burn through one GB per full day.
  • On the remote desktop, visit a site like http://www.speedtest.net, you might be surprised!
  • It is recommended to use a tool like Dropbox ( https://db.tt/kzDejJq0 ) to sync your data to your new remote desktop. With high-speed Internet access, even larger Dropbox accounts are synced within a short time. You might want to redo the instance configuration and add a larger hard disk, though.
  • Amazon also provides so called “Work Spaces,” including a Microsoft Office license. That type of server is meant to actually be a desktop replacement. The downside is that you would have to use the Amazon remote desktop software which turned out to be very unstable during my tests.

Enjoy!

Categories
Business Language Philosophy Productivity

Guidelines for Productive Discussions

By Clemens Lode on Thursday, February 12, 2015 at 10:06pm

Do you want your discussions to be productive and draw people’s attention? Here are guidelines to help you become productive in any discussion you may encounter. Before posting, please keep these following guidelines in mind:

First of all, if you are linking to an article or video, summarize it. A discussion needs to be possible even if the person is not reading or watching the whole thing. Moderators need to be able to determine if something posted is spam or if it’s a worthwhile topic to discuss. Quote the most relevant part of the link and give context as to why the link is relevant.
It is wrong to say, “Oh, boy.”
Rather one should say, “ARI starts a new headquarters in Europe in 2016. “” I think this is relevant because this marks a major change in policy and we should all look into it as to how we can help.”

Next, summarize your position. Add it to the original post or in a reply to your thread. If your position is controversial, provide a more thorough explanation in the original post or a link to an essay you have written.
Don’t say, “I think Ayn Rand got it wrong. Consciousness creates existence.”
Rather say, “… and here is why I think so: *link to your essay* Is my argumentation sound? What was Ayn Rand’s argument in that regard?”

Then, clearly define the limits of the discussion. People should be able to judge if their post is on-topic by reading the original post.
Saying, “Abortion. Democracy. Capitalism. God. Go!” is wrong.
What’s right is saying, “In this thread, I would like to discuss land property rights. Here is the definition: . Given an outside military threat, is it an initiation of force for the army to use that land? For example ”

Try to give complete answers. Do not simply link to an answer. Many questions will repeatedly show up here, and most questions are already answered in the literature. But there is a reason as to why people make the effort to create a thread in order to ask a question. You can link your answer, but please summarize its core message. If you cannot summarize your answer from the book, you probably have not read or understood the book in question. If someone asks you for an address, a good answer is to point him/her to the direction of the building. A bad answer is when one being pointed to the local tourism information booth.
Refrain from saying something like, “You haven’t read the book, have you?”, “A true Objectivist wouldn’t ask such a question.”, “This is a dumb question.”
Instead say, “Ayn Rand wrote an essay on this very subject in… Her idea was to start from the homesteading principle and explain the parallels to modern broadcast technology. … .”

Make sure your statements are verifiable when you give them. Be specific, give concrete sources and concrete examples.
It’s wrong to say, “Some scientists claim…”
But it’s right when you say, “We know from experiments that … . See reference , , and . Their main conclusion was…”

Also never let the other person be part of your argument. While logical fallacies are commonplace in discussions (knowingly and unknowingly), ad hominem arguments are usually the most destructive arguments. Remember that there are potentially thousands of people who would follow the thread you are about to derail. Even if you have reasons to believe that the other person is an idiot, it is not up to you to “repair” the situation. Report the post and let an admin deal with it.

Finally, be very careful when posting a sarcastic or humorous post. Not everyone shares your humor. If possible, make clear that the statement or post was not meant seriously. If you are a sarcastic person, add a “;)”. Yes, this is an Objectivist group, but besides a superfluous check of the profile of each member we add, people here are not necessarily Objectivists. And even among Objectivists, they have completely different sense of humor from each other. Do not mistake similar philosophic views with similar personality.

There you have it guidelines to help you become productive in any discussion. As you have read, most of these guidelines are ‘obvious.’ But it’s easy to miss them in the heat of an argument or when casually posting an article. These are based on experience as to what type of threads derail and what type of threads actually help the readers share their ideas and learn from other’s as well. If another topic develops within the discussion, an admin will then create a new thread for that new topic. These guidelines will still help no matter what type of discussion or topic you are in.

Categories
Business Productivity

Productivity

Learning Ways on How to Be Productive

Let me start this with a question, how can we be productive at work or even in school? Let me tell you, if you already know what to do, then delegate. This way, the work itself becomes more like a game. But, what if you have no one to delegate? Well, hire someone. It doesn’t necessarily have to be someone who knows how but one who is eager to learn. It’s better to have somebody willing to learn than to hire someone who thinks he knows it all, even though he does not and then fail big time.

Productivity should surround around knowledge management. Get a structure in order wherein you can share knowledge with others and work as a consultant to them.

A common practice in working in teams is creating a matrix comprising of all the skills people have such as primary and secondary skills.  And then, assigning people to work on tasks utilizing their secondary skills while supervising the people working on a task requiring the supervisor’s primary skill. Now that should be easy. The topic here is knowing what to do in most case but not in absolutely all cases.

There are certain tasks that will involve further study or scrutiny. Break down the tasks according to those which you are struggling with and those which could be done by someone else. Then separate these tasks into roles and delegate them. Now even if you will have to do all the work by yourself in the end, doing this helps you to stay focused. You can still delegate work for yourself. The foundation of a well-defined ‘work package’ helps achieve a milestone easier than simply mixing up management and carrying out projects.

In my case, even if it takes longer, I still delegate more and more tasks out to people. I need to DEFINE what I actually want them to achieve, and that alone is already half of the workload. Even if the other person does his/her job sloppily and I have to do some corrections (or even do most of their work myself), I am still light-years ahead compared to doing everything myself without a plan. Having an employee helps insofar as much as you are forced to put what you want into words while being able to ‘weasel your way out’ than if you keep the tasks at hand undefined and unspoken.

Think of the concrete goal you need to achieve, like for instance, your attendance and participation in every lecture and exam. Learn to express your goals.  Focus on these goals. Know what you need to deliver. Evaluate whether you have been successful in attaining your goals or not. Determine if you have excellently brought your tasks and goals into completion. Set a definite time frame to complete your goals. Do not procrastinate.

If you have to take a certain curriculum, do so and then use it to learn other valuable skills. Get familiar with the internet like Github or any other repository.  Create an open source project, put your agent on the site and invite others to discuss ideas on ways to improve it. Remember to be open to everybody’s suggestion. It doesn’t mean you have to do everything being suggested, but it helps to have varied ideas. Ultimately, it altogether depends on the set goals.

What happens if you hit the deadline and your program does not perform well? Does that mean you freak out? Or do you do something to improve your next project? Perhaps, an even more important lesson is to know one’s own limitations.  Ask someone to coach you in the subjects you have insufficient knowledge of. Accepting one’s own limitation will help you achieve higher and better goals. This helps define one’s own character better. Like with sports, wherein you test out your limits; you’ll recognize how far you can go or can contribute.

You would probably agree with me when I say that the best job is doing what you love, but if you can’t have the job you love then learn to love the job you’ve been given.

In personality psychology, there is this dichotomy wherein you are good at one thing, but you long for another. For example, I am good at coming up with fresh ideas and relating these to people, but what I am really longing for is to work with businesses and systems. I like to combine everything into one. Usually, it’s best to partner with someone who covers the parts you long for. Find someone who deals with ideas and people, and then another who deals with details and management. Well, you are automatically drawn to a person who shows strengths in those qualities; simply because you can see that they need much less effort to do something that normally takes so much time and effort. Likewise, they are drawn to you, as you (ideally) show the opposite strengths. Again, that’s psychology, not philosophy.

When we came into this world we weren’t handed out with identical brains. By nature, some actions require either some more or much less energy. Some are more focused on the intimate, minute details while others are more focused on the broader scope of the whole picture. The actual grouping of people into those two concepts is more or less arbitrary. But see it as a form of division of labor with the goal of minimizing the required mental effort to accomplish a certain task.

So then, how can we be productive? Delegate tasks to people who are willing to learn. Be open to suggestions and don’t procrastinate. I tell you, you are on your way to being productive whether at work or in school.