Questions tagged [macros]

{macros} is for questions specifically concerning TeX's macro processor. Note that, because TeX uses macros ubiquitously, most questions about code that uses macros are not looking for information about how macros work, and so are not appropriate for this tag.

179 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
1
vote
0answers
30 views

`\show` for macro arguments

For debugging purposes, I want to write to the log what is actually passed to a macro as argument. A naive \newcommand\test[1]{\show#1} obviously doesn't do the job. So how can I printout a list of ...
1
vote
0answers
21 views

Merging lyx files involving different (perhaps intersecting) macros

I want to merge two files written in LyX by my colleague and me. The problem is both of us use self-written macros for writing things shortly. We want to merge our files, and use a chapter my ...
1
vote
0answers
36 views

Prevent selection of some pdf sections

In order to avoid the selection of a part of a pdf, I use this command: \usepackage{accsupp} \DeclareRobustCommand\squelch[1]{% \BeginAccSupp{method=plain,ActualText={}}#1\EndAccSupp{}} For ...
1
vote
1answer
131 views

How do I customize Circuit_macros in listings?

MWE: \documentclass{article} \usepackage{xcolor} \usepackage{listings} \definecolor{Others}{RGB}{0,110,40} % Green \definecolor{Character}{RGB}{146,76,157} % Purple \definecolor{Number}{RGB}{176,...
1
vote
0answers
34 views

it is better to create a command that passes as argument paragraphs or better to create an environment?

My purpose is to create a command that admits two arguments, namely, a title and content (paragraphs), for example, \newcommand{\mytxt}[2]{\clearpage% \MakeUpercase{\bfseries #1}\newline\newline #2 \...
1
vote
0answers
235 views

Macro trigger in TeXstudio does not work

I am trying to define a macro in TeXstudio. When I am typing "itemslide" nothing happens.. Only when I am typing "\itemslide" the text is replaced by the content of "LaTeX-Text". What am I doing ...
1
vote
0answers
57 views

Own command for references - TexStudio does not recognize referenced labels

I'm currently writing a thesis using LaTeX. I have a couple of figures (diagrams) in my document and wanted to reference them in a more convenient way than always writing "bla in figure \ref{labelname}...
1
vote
0answers
83 views

counters, newcount and pgfcalendar, macros

I am trying to use the pdfcalendar library, but I think I'm confused by the definitions. My Question: What kind of LaTeX counter/macro/variable can I use with pgfcalendar functions? Do I have to ...
1
vote
0answers
36 views

Using \begin{rule} as theorem-like environment

I tried using amsthmand thmtools to define a theorem-like environment called rule. Turns out this is a bad idea, as amsthm then tries to define \rule and \@rule. Now, the correct solution is ...
1
vote
0answers
40 views

Find and replace text in bibentry using macros

I want to be able to display a bibliography entry but I want to highlight some part of it, specifically some author, but not all. So far I am able to create the bib entry in the middle of the text, ...
1
vote
0answers
64 views

LyX: Create a menu with predetermined topics

I'd like to add a menu to LyX with a list of topics that the use can select. Each topic in turn, when selected, will create an itemized list of built-in questions in the document. I've read about ...
1
vote
0answers
36 views

Problem on list in custom command using adjustbox

I have a problem, that seems to be quite common : code expansion. I have declared a command, that use an other command that use adjustbox. So far so good, until I need to pass to the first command a ...
1
vote
0answers
52 views

How to store multiple fragile definitions for re-importing later

I'm posting this in case it's useful to anyone; it's not actually a question. Commands defined inside environments like enumerate are automatically fragile, and are lost outside the environment. ...
1
vote
0answers
186 views

Concatenate string for \includegraphics

I'm trying to create a string (caseid) to which I can concatenate different string inside \includegraphics. \documentclass{article} \usepackage{graphicx} \begin{document} \begin{figure}[...
1
vote
0answers
102 views

Sync the flow of two texts

We are writing a textbook that has content for the student and recommendations directed to the teacher, something like this: How can we sum $\frac{3}{7}$ with $\frac{7}{3}$? \begin{teacher} A ...
1
vote
0answers
44 views

Output plain ascii text to output file (expandable \IfStrEqCase with multiple matches)

This question is specfically about an expandable version of \IfStrEqCase (with multiple matches) as per Modified \IfStrEqCase with multiple matches per case. However, in case this is an x-y problem, ...
1
vote
0answers
70 views

Is there a way to make macros for building this kind of table?

Is there a way to make macros that makes a table like this where the colors changes according to the different cells, even though the first couple of cells are a multirow cell. I need to make 16 of ...
1
vote
0answers
103 views

How can I assign a specific `medmuskip`/`thickmuskip` for a particular binary op./rel., without affected the spacing for other operators?

I know that one can mess with medmuskip for binary operators, and thickmuskip for binary relations, to change the spacing around them: How to change default for spacing around binary relations? ...
1
vote
0answers
110 views

How \readlist* macro from listofitems package remove leading/trailing spaces

This question follows How to remove space before or after argument then compare it with a string The answer from @StevenB.Segletes use \readlist* macro which remove leading/trailing spaces from an ...
1
vote
0answers
107 views

newcommand and index

I want to have an index entry referencing to another entry withought adding a comma. I currently do this with: \newcommand{\gobblecomma}[1]{} And then in the text itself when an entry occurs: \...
1
vote
0answers
130 views

“End-of-story mark”

I try to get in the last line of all my document a black square to mark the end of article. So, this is my MWE: \documentclass{article} %\usepackage[french]{babel} %\useppackage{lipsum} \usepackage{...
1
vote
0answers
60 views

Include external test results in my document

I have a LaTeX document which contains an environment I use to layout specifications of integration tests of a software system. One thing I would like to do is to have the results of the last run (if ...
1
vote
0answers
91 views

How to use lilypond macros in different blocks

Code: \documentclass[12pt]{article} \usepackage[utf8]{inputenc} \begin{document} First variant \begin{lilypond} \version "2.17.27" \language "english" D = \relative d {d4 <f a d>} A = \...
1
vote
0answers
151 views

\newcommand doesn't work with \tikzparentnode. Undefined Control Sequence error

I can't input \tikzparentnode command inside \newcommand. It returns Undefined Control Sequence error. This is my command definition: \newcommand{\childstyle}[4] { #1/.style = {fill=#2, grow=...
1
vote
0answers
122 views

Naming conventions for dummy commands

Are there any conventions concerning the naming of "dummy" commands that are used in a restricted scope for specific purposes? For example, I am checking if slashes (/) are contained inside a string ...
1
vote
0answers
50 views

LyX | Replaced Typed Symbol with Macro

In LyX, I've defined the following Macro: (it's with \stackrelthree) My question is: is it possible to press on the = button on my keyboard, and replace the input to LyX to the macro, instead of the ...
1
vote
0answers
149 views

Replace svg with svg-inkscape to get rid of subfig

I would like to include SVG images in my LaTeX document. I also would like to use subcaption for subfigures. I am using the following folder structure: <project path>/Document/document.tex for ...
1
vote
0answers
37 views

Problems with # while naming the arguments and drawing in TikZ

I am totally new to macros. I have the code which I would like to put into a separate command to avoid code duplication \documentclass{article} \usepackage{graphicx} \usepackage{balance} % for \...
1
vote
0answers
251 views

Citing with the short title of a book

I was wondering how I could cite the short title of a book. For instance: @book{Blackstone59, Address = {London}, Author = {Blackstone, William}, Date-Added = {2017-03-15 11:58:40 +0000}, ...
1
vote
0answers
148 views

Preserve EPUB page breaks in pdf generated from pandoc

I'm trying to generate pdfs from EPUB files using pandoc and a custom XeLaTeX template. These EPUB files are all made up of several chapters stored as separate xhtml pages, and any ereader would ...
1
vote
0answers
62 views

Modify `\funcdef` macro to use `pgfkeys` instead of `keyval`

I attempted to modify the \funcdef macro from egreg's solution from A macro adding or removing parenthesis automatically to use pgfkeys, but am running into some difficulty (probably related to some ...
1
vote
0answers
152 views

Environment for respecting spaces

I am using XeLaTeX and I want to create a new environment which — among other things — should respect all spaces. The code presented in this answer works well for me. But how to create a new ...
1
vote
0answers
53 views

remove pipe chars in latex doc

My Doxygen project generate latex files. I can have a custom LaTeX header, but beyond that I don't have much control over the LaTeX content generated by Doxygen. Unfortunately the table formatting in ...
1
vote
0answers
76 views

Best practices for “factoring” relatively small snippets of shared code

My particular use case is that I have a long academic CV, and a short résumé. The two of them share a reasonable amount of textual content, but, for example, the order of the content varies, some ...
1
vote
0answers
93 views

Package that fills pages to total number of pages devideable by 4, 8, 16

I'm doing a package right now, which is capable of filling in empty or custom pages to get a total number of pages which is devideable by a defined number. I just want to make sure, that a package ...
1
vote
0answers
87 views

Macro: Replace all occurrences of words which are identical to content of \label{…} into \nameref{…} (unless of course the \label itself)

This question is a follow-up of Macro: Replace all occurrences of a word, but would like to ask for a possibility to do the same with words (e.g. foo) that are identical to the contents of certain or ...
1
vote
0answers
405 views

Automatic lettrine in chapters

I'm trying to get lettrine dropcaps applied automatically on the first word of each chapter. I found some code here: http://dererumnatura.us/archives/2009/02/automatic-usage.html which I've tried ...
1
vote
0answers
110 views

Terminate and Start and environment from within the environment

How can I terminate and resume an environment by another environment? This also seems to have broken the resume feature which was resolved in Define a List that is Always Resumed. The code \begin{...
1
vote
0answers
102 views

A \newcommand type option that runs all subarguments and saves static text

I am trying to write code that uses sage in it, and have a bit of a problem with randomizing stuff around the code. The sagetex part isn't too important (I don't think), what is important is that if I ...
1
vote
0answers
41 views

Expanding to something missing an argument

I have a very weird behaviour where replacing something by its extension removes an error. Here's the problem: \documentclass{article} \usepackage{xparse} \usepackage{mathpartir}% http://cristal....
1
vote
0answers
150 views

Display shortcuts other than urls with href

Big picture, I am trying to develop an approach that will allow me to store the latex commands and labels (pre-expansion) that I use to typeset dynamic text (bib entries with cite, cross referencing ...
1
vote
0answers
90 views

How to split a string to figure float with figure name, label and caption?

I am struggling with a shorthand macro that converts a string to a figure. At the end is a working, but unstable version what I am trying to do. The goal is to parse make a command (or macro) like ...
1
vote
0answers
116 views

Is there a good way to automatically generate a list of commands/environments defined in the preamble?

Background I have seen beautiful manuals with commands and descriptions of what they do. I have a shared preamble (edited by multiple people and used for multiple documents) that has a multitude of ...
1
vote
0answers
155 views

Is it possible to use `renewcommand` to replace the `hyperref` command with `hyperlink`?

I am using Beamer with Hyperref, and I have a problem with the \hyperref command. The link is active, but it sends me to the first slide of the talk. I've read here in the Troubleshooting section (...
1
vote
0answers
53 views

Preprocessing code for cross-compilation of two different projects?

I have two different projects, which are the LaTeX code for English and Greek for the same book. Does LaTeX support preprocessing code (without using any external tools) that would allow two ...
1
vote
0answers
205 views

Problem with answers using hyperlinks and tbox

I have minor problems with the solutions shown in Hyperlink with answers package I wanted to make a macro which takes solution and exercise as arguments, uses a button like mutual reference, and ...
1
vote
0answers
102 views

indexing with sed using less brittle \gls and \acs and \index commands

I'm writing a book for which I produce sections for glossaries, acronyms and index entries using the glossaries, acronym and makeidx packages on a template derived from the Springer book template. To ...
1
vote
0answers
48 views

Can I use Writer2LaTeX and the `mla-paper` style together?

I use LibreOffice 4.1.3.x, and have had success using a patched version of Writer2LaTex with documents created in LibreOffice Writer. I want to create a (sub?)filter for Writer2LaTeX that allows me ...
1
vote
0answers
87 views

Bibtex-like macros organising software

From what I gather (I don't use them, and have never actually managed to get it to work - though this is not my issue), bibtex/biber uses a database of references, alongside an ancillary file created ...
1
vote
0answers
309 views

How to make a package using sagetex and sage-commands

I am trying to make my own package building on sagetex. It starts with \RequirePackage{sagetex} and I want it to execute some 'sagesilent' code as for instance \newcommand{\loadsagefunction}{ \...